我是弹性搜索和Java的新手。
我有一个像
这样的JSON对象{
"keyword":null,
"size":[],
"matchResults":
{
"Data": ["first" "Second"]
},
}
我想搜索“matchResults”字段并期望输出如下:
获取这些结果我在Java代码中使用matchQuery,
Map<String, List<String>> matchResults = request.getMatchResults();
if (matchResults != null) {
for (Map.Entry<String, List<String>> filter : matchResults.entrySet()) {
logger.info("key is" );
List<String> values = filter.getValue();
if (values != null) {
query = query.filter(QueryBuilders.matchQuery(filter.getKey(), values));
}
}
}
但这会产生以下错误
{
"messages": [
"{\"root_cause\":[{\"type\":\"parsing_exception\",\"reason\":\"[match] unknown token [START_ARRAY] after [query]\",\"line\":9,\"col\":23}],\"type\":\"parsing_exception\",\"reason\":\"[match] unknown token [START_ARRAY] after [query]\",\"line\":9,\"col\":23}"
],
"data": null,
"message": "{\"root_cause\":[{\"type\":\"parsing_exception\",\"reason\":\"[match] unknown token [START_ARRAY] after [query]\",\"line\":9,\"col\":23}],\"type\":\"parsing_exception\",\"reason\":\"[match] unknown token [START_ARRAY] after [query]\",\"line\":9,\"col\":23}"
}
不确定是什么导致了这一点。