Java multi search result repetition

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()
qb2 = QueryBuilders.matchQuery("resourceType", "user");
SearchRequestBuilder srb2 = client.prepareSearch()
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:

    qb1 = QueryBuilders.queryStringQuery(key);
QueryBuilder qb = QueryBuilders.boolQuery();

I'd write:

BoolQueryBuilder qb = QueryBuilders.boolQuery();

if (!key.equals("")) {

It will report error that can't resolve method must.:neutral_face:

I updated my answer

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.