问题
QueryBuilder queryBuilder =
QueryBuilders.multiMatchQuery(deptIdList, "data.deptId", "modifiedData.deptId");
代码报错
{
"data": {
"errorCode": 500,
"message": "Elasticsearch exception [type=parsing_exception, reason=[multi_match] unknown token [START_ARRAY] after [query]]"
},
"status": 0,
"message": "Elasticsearch exception [type=parsing_exception, reason=[multi_match] unknown token [START_ARRAY] after [query]]"
}
原因:
QueryBuilder queryBuilder =
QueryBuilders.multiMatchQuery(deptIdList, “data.deptId”, “modifiedData.deptId”);
multiMatchQuery这个API,第一个参数不支持List类型, 虽然传List没报错, 但是往ES发送查询请求的时候就会抛异常出来文章来源:https://www.toymoban.com/news/detail-729829.html
解决办法:
传一个字段, 如果你想多字段in查询,就用类似下面这样写法就可以了.文章来源地址https://www.toymoban.com/news/detail-729829.html
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
for (String deptId : stringList) {
boolQueryBuilder.should(QueryBuilders.multiMatchQuery(deptId, fieldNames));
}
到了这里,关于Elasticsearch exception [type=parsing_exception, reason=[multi_match] unknown token [START_ARRAY] af的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!