Nested document full text query with filter capability

Hi dear
My index mappings and sample data as follows

I need full text search on these type of documents with following criteria:

  1. country is one input of this search

  2. If I search "Alex 4455" and country is "xxx" this document will be matched and return following document.

  3. If I search "Landing" and country is "xxx" this document will be matched and return following document.

  4. If I search "Martin 4455" and country is "xxx", result is null.

In the other hand, I need combined_field in nested document with filter capability!!!

Hi John,

Welcome to the community! For next time please include your mapping as code rather than images as it makes it easier to read and copy.

It looks like you will need a nested query to search this structure, and to get the member criteria that matches you'll want to use inner_hits:

An example to get you started and see what the response is like would be something like the below. You'll see that within inner_hits in the response the matching members in the nested structure are returned.

GET manager/_search
{
  "query": {
    "nested": {
      "path": "member",
      "query": {
        "bool": {
          "must": [
            { "match": {
              "member.address": "Landing"
              }
            },
            {
              "match": {
                "member.country": "xxx"
              }
            }
          ]
        }
      },
      "inner_hits": {
      }
    }
  }
}

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