Search template based on list

Hi All,

I have an index (contains translations) with the following mappings:

document_name: keyword,
...
EN: {
  content: text,
  stored_by: keyword,
  stored_at: date,
  ...
}
<<lang code>>: {
  content: text,
  stored_by: keyword,
  stored_at: date,
  ...
} 

Till now the 3rd party application has searched on the following way:

GET translation-*/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "match" : {
            "EN.content": {
              "query": <<query text>>,
              ...
            }
          }
        }
      ],
      "should": [
        {
          "exists": {
            "field": <<language code 1>>
          }
        },
        {
          "exists": {
            "field": <<language code 2>>
          }
        },
        {
          ...
        },
        {
          "exists": {
            "field": <<language code n>>
          }
        }
      ],
      "minimum_should_match": 1
    }
  },
  "_source": [
    "document_name",
    <<language code 1>>,
    <<language code 2>>,
    ...,
   <<language code n>>
  ]
}

So I would like to create a search template where the parameters are the following:

  • query text
  • list of language codes

Are there any way to create something like that? Thanks

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