我想创建一个NativeSearchQuery来搜索我们映射的所有字段,_all标记就是我所需要的,但是在代码中构建它并不像我喜欢的那样:
NativeSearchQuery query = new NativeSearchQueryBuilder().withIndices(indexName)
.withQuery(QueryBuilders.matchQuery("_all", request.getSearchTerm().getSearchString()))
.withPageable(new PageRequest(request.getPaging(), request.getMaxResults()))
.build();
创建一个如下所示的查询:
{
"match" : {
"_all" : {
"query" : "<searchterm>",
"type" : "boolean"
}
}
}
但要实现我的意图,它必须看起来像那样:
{
"match" : {
_all : {
"query" : "<searchterm>",
"type" : "boolean"
}
}
}
任何想法?