When I use java multi search api 5.2.2, there are many duplicate data in the response. Is there any other api which can remove these duplicate data?
No. I'd not use multi search in such a case
Maybe I didn't describe clearly. For example:
qb1 = QueryBuilders.queryStringQuery("key");
SearchRequestBuilder srb1 = client.prepareSearch()
.setQuery(qb1).setIndices(indexName)
.setTypes(type).setSize(size);
qb2 = QueryBuilders.matchQuery("resourceType", "user");
SearchRequestBuilder srb2 = client.prepareSearch()
.setQuery(qb2).setIndices(indexName)
.setTypes(type).setSize(size);
MultiSearchResponse sr = client.prepareMultiSearch().add(srb1).add(srb2).get();
In fact, result has one hit, but there are two in the response.
Why won't you use a Boolean Query here instead then?
1 Like
Is there any example or docs about boolean query?
Can this method add query dynamically? Such as:
if(!key.equals("")){
qb1 = QueryBuilders.queryStringQuery(key);
}
QueryBuilder qb = QueryBuilders.boolQuery();
qb.must(qb1);
I'd write:
BoolQueryBuilder qb = QueryBuilders.boolQuery();
if (!key.equals("")) {
qb.must(QueryBuilders.queryStringQuery(key));
}
It will report error that can't resolve method must.
I updated my answer
1 Like
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.