Filtering by "value X and minimum one more value"

Hello everyone,
I have a field
"language" that might contain values in any kind of ordering (example: "[de, en, fr]" or "[en]" or "[fr, de, en]"

I need to filter by "language: (en and minimum one more language)".
Any ideas please?

Hey @Smoerble_Smorebrod, what do the Elasticsearch mappings look like for the field you're looking to filter on?

If you create an index with a field-type of keyword:

PUT smoe
{
  "mappings": {
    "properties": {
      "language": {
        "type": "keyword"
      }
    }
  }
}

And index a document into it, you can include multiple values for that field:

POST smoe/_doc
{
  "language": ["fr", "en", "de"]
}

You can then search en and one more language using the following:

POST smoe/_search
{
  "query": {
    "bool": {
      "filter": [
        {
          "term": {
            "language": "en"
          }
        },
        {
          "terms": {
            "language": [
              "fr",
              "de"
            ]
          }
        }
      ]
    }
  }
}

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