我在java elastisearch客户端v6.6.0中有建议问题 我有这样的文件:
{
"_index": "index_a",
"_type": "type1",
"_id": "id1",
"_score": 0.0005112039,
"_source": {
"city": "city name",
"someFeature": false,
"suggestions": [
{
"input": "city name",
"weight": 492
},
{
"input": "city",
"weight": 498
},
{
"input": "name",
"weight": 498
}
]
}
}
然后我创建请求:
SearchResponse suggest(String index, String type,
CompletionSuggestionBuilder completionSuggestionBuilder,
QueryBuilder queryBuilder) {
return elasticClient
.prepareSearch(index)
.setTypes(type)
.suggest(new SuggestBuilder().addSuggestion(type,
completionSuggestionBuilder))
.setPostFilter(queryBuilder).get();
}
completionSuggestionBuilder基于 suggestions 字段,而 queryBuilder 是boolQuery:
QueryBuilder queryBuilder = QueryBuilders.boolQuery()
.must(QueryBuilders.matchQuery("someFeature", false));
,但条件 someFeature = false 被忽略。响应包含具有 someFeature = true 的元素。 我尝试使用setQuery代替setPostFilter,但是它也不起作用。 可以和其他查询一起建议吗?我在CompletionSuggestionBuilder中找不到任何选项来过滤 someFeature 字段中具有错误值的文档。