Query on fieldname with wildcard?

Hi,

In order to support multi-lingual documents, we stored them with the suffix of the language code, such as:
{
"description_EN": "My Description",
"description_FR": "Ma Description"
}

We do not know in advance, in which language(s) documents are generated and we support up to 24 languages. Mappings for the 24 languages were created.

Therefore my question:

How can I run a query against all documents, not knowing the "field name" suffix?

I would need something like;

..."wildcard": {
"description_*.keyword": {
"wildcard": "a"
}
}

but this does not work...

Any help would be more than welcome.

Many thanks in advance,

One way which could work is using the query_string / simple_query_string query.

{
  "query": {
    "query_string": {
      "query": "a*",
      "fields": [
          "description_*"
        ]
    }
  }
}

They allow wildcards in both field names and query terms

thank you so much. It works !! :slight_smile:

Cool! :smiley: happy coding

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