#TermsQuery in Elasticsearch

1 messages · Page 1 of 1 (latest)

wheat fossil
#

Hi everybody. I'm playing with elasticsearch a bit to understand it better (fairly new to me). Now I have created a getTermsQuery method. Which gets a field and a terms collection in the parameters. And all it actually does is check whether the first term in the terms collection matches the field. But now I have multiple objects with a field(id) and a terms collection with multiple ids of objects that I want to retrieve. How can I change this so that it doesn't just grab the first one, but checks with each id in the terms collection for a hit with an object?

  private static Query getTermsQuery(final String field, final Collection<String> terms) {
    return Query.of(qb -> qb.match(tb -> tb.field(field)
                                           .query(q -> q.stringValue(terms.stream().findFirst().get()))));
  }
pearl ginkgoBOT
#

<@&987246584574140416> please have a look, thanks.

pearl ginkgoBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.