Multi word, single field AND query

Hi. I have a field TAGS that takes in a List of Strings. I want the user to specify the tags and the result should be records that contain at least all of the tags. For example, if she searches for A, B,C , i want the records like A,B,C,D or A,B,C to be returned but not records like A,B,D or A,B.

The TERMS QUERY (https://www.elastic.co/guide/en/elasticsearch/reference/5.6/query-dsl-terms-query.html) would return A,B,D and A,B as well which i do not want.

I searched for an alternative way to do this (https://www.elastic.co/guide/en/elasticsearch/guide/current/match-multi-word.html#match-multi-word) but that is basically searching for each tag separately and then performing an AND operation which seems sub-optimal.

I'm using ES 5.3. Could anyone present a better alternative? Thanks for your help!

If you are able to upgrade to version 6.2, you should be able to do this through the terms set query. If you cannot upgrade, a query requiring each term separately might be the best option.

Yes I'm aware of terms set query but I can't upgrade at this time. Thanks for your answer!

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