java - 使用用于 rest-high-level-client 的 java 代码将完成建议添加到索引
问题描述
我的用例是,我的索引中需要有 4 个字段可以通过完成建议进行搜索,但是我的一些字段在插入时可以为空或 null,我在创建索引时尝试使用以下代码,但这会引发错误,因为其中两个插入时我的字段为空
"CustomerName": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword"
}
},
"copy_to": [
"Suggestions.CustomerName"
]
},
"FullAddress": {
"type": "keyword",
"copy_to": [
"Suggestions.FullAddress"
]
},
"Contact": {
"type": "keyword",
"copy_to": [
"Suggestions.Contact"
]
},
"CustomerId": {
"type": "keyword",
"copy_to": [
"Suggestions.CustomerId"
]
}
如何使用 java 代码在弹性搜索中添加完成建议?我正在使用以下 Maven 依赖项:
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>6.2.3</version>
</dependency>
解决方案
推荐阅读
- networking - 如何使在 Virtual Box 中运行的应用程序可通过公共互联网访问
- for-loop - Kotlin For 循环,有点困惑
- google-sheets - 在单个单元格中包含多个值的表单响应
- r - for循环值被视为R中数据表列代码的字符
- django - 重塑 django 数据,通过外键对它们进行分组
- flutter - 如何在颤动中绘制其他应用程序?
- mongodb - 运行 MognoDB 的聚合方法时出错
- firebase - 按两个 where 条件过滤 - Firebase 控制台
- go - 如何打印链表
- javascript - Django admin list_display 在鼠标悬停时显示全文