Search-as-you-type inside arrays

Hi there,
I am trying to implement a search-as-you-type query inside an array.
This is the structure of the documents:

    {
              "guid": "6f954d53-df57-47e3-ae9e-cb445bd566d3",
              "labels": [
                {
                  "name": "London",
                  "lang": "en"
                },
                {
                  "name": "Llundain",
                  "lang": "cy"
                },
                {
                  "name": "Lunnainn",
                  "lang": "gd"
                }
              ]
            }
     }

and up to now this is what I came with:

    {
      "query": {
        "multi_match": {
          "fields": ["labels.name"],
          "query": name,
          "type": "phrase_prefix"
        }
    } 

which works exactly as requested.
The problem is that I would like to search also by language.
What I tried is:

{
  "query": {
    "bool": {
      "must": [
        {
          "multi_match": {
            "fields": ["labels.name"],
            "query": "london",
            "type": "phrase_prefix"
          }
        },
        {
          "term": {
            "labels.lang": "gd"
          }
        }
      ]
    }
  }
}

but these queries act on separate values of the array. So, for example, I would like to search only Welsh language (cy). That means that my query that contains the city name should match only values that have "cy" on the "lang" tag. How do I write this kind of query?

Thanks a lot for your time guys

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