In elasticsearch there are documents with a list field:

"tags": ["ENUM_A", "ENUM_B", "ENUM_C"] 

It is required to find documents in which the list field contains at least one entry from the list in the request (i.e., the example should match the ["ENUM_A", "ENUM_D"] and not match the simple ["ENUM_D"] ). How to do it? The terms filter did not work (maybe I just didn’t cook it right).

update: terms for some reason works great on numbers, but does not work on strings.

    1 answer 1

    The answer turned out to be quite simple - Elasticsearch, by default, decomposes lines into separate components, applies lowercase operations to them, and searches for them. In my case, I fed the enum values ​​directly to elastic, and he kept them inside in the form of the same strings, but in lower case, and searched for the terms filter among values ​​of a different kind than I expected. To get rid of this problem, you must set the mapping not_analyzed for the desired field.

    Dock: https://www.elastic.co/guide/en/elasticsearch/guide/current/_finding_exact_values.html#_term_filter_with_text