Replicating "_all" functionality in v6 via "copy_to" mapping parameter?

For some reason we always assumed that removal of the "_all" field in v6 is not a big deal and we can always create a custom "_all" field via "copy_to" mapping option.

But it appears that "copy_to" cannot copy fields from the nested documents to the parent at all. It looks like this question has been raised multiple times on these forums and github and the answer was always "no nested documents support"

Is that an accurate statement? Is there any way to replicate v5 "_all" field functionality in v6 with "copy_to" mapping when you have several nested documents?

If yes - could you provide an example?

If no - could you update misleading docs on "copy_to" that strongly imply that it possible to have custom "_all" field.

Thank you

Alex

What problem are you running into exactly? The GH issue you linked is about using copy_to to copy from one nested type to another nested type, not about copying to the parent. Copying from a nested type to the parent should not be a problem.

The following works for me:

PUT my_index
{
  "mappings": {
    "_doc": {
      "properties": {
        "foo": {
          "type": "text"
        },
        "my_nested_type": {
          "type": "nested",
          "properties": {
            "bar": {
              "type": "text",
              "copy_to": "foo"
            }
          }
        }
      }
    }
  }
}

PUT my_index/_doc/1
{
  "my_nested_type": {
    "bar": "test"
  }
}

GET my_index/_search
{
  "query": {
    "match": {
      "foo": "test"
    }
  }
}

This is awesome. Thank you for the working example! We did not define the "virtual" field in the mappings in our tests and this is why it did not work. Now we have a simple search solution again! Yay :slight_smile:

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