# Replicating "\_all" functionality in v6 via "copy\_to" mapping parameter?

**URL:** <https://discuss.elastic.co/t/replicating-all-functionality-in-v6-via-copy-to-mapping-parameter/147787>\
**Category:** Elasticsearch\
**Created:** [September 7, 2018, 11:37pm UTC](https://discuss.elastic.co/t/replicating-all-functionality-in-v6-via-copy-to-mapping-parameter/147787 "2018-09-07T23:37:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexu](https://avatars.discourse-cdn.com/v4/letter/a/5e9695/32.png) [@alexu](https://discuss.elastic.co/u/alexu)\
**Post date:** [September 7, 2018, 11:37pm UTC](https://discuss.elastic.co/t/replicating-all-functionality-in-v6-via-copy-to-mapping-parameter/147787/1 "2018-09-07T23:37:59Z")

</div>

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"

> <https://github.com/elastic/elasticsearch/issues/23077>

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

---

<div class="post-metadata">

**Author:** ![abdon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abdon/32/9195_2.png) [@abdon](https://discuss.elastic.co/u/abdon)\
**Post date:** [September 9, 2018, 11:33am UTC](https://discuss.elastic.co/t/replicating-all-functionality-in-v6-via-copy-to-mapping-parameter/147787/2 "2018-09-09T11:33:24Z")

</div>

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:

```auto
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"
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![alexu](https://avatars.discourse-cdn.com/v4/letter/a/5e9695/32.png) [@alexu](https://discuss.elastic.co/u/alexu)\
**Post date:** [September 10, 2018, 5:35pm UTC](https://discuss.elastic.co/t/replicating-all-functionality-in-v6-via-copy-to-mapping-parameter/147787/3 "2018-09-10T17:35:00Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 8, 2018, 5:41pm UTC](https://discuss.elastic.co/t/replicating-all-functionality-in-v6-via-copy-to-mapping-parameter/147787/4 "2018-10-08T17:41:56Z")

</div>

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