# Transitioning from \`path\` to \`copy\_to\` with extracting field nested object

**URL:** <https://discuss.elastic.co/t/transitioning-from-path-to-copy-to-with-extracting-field-nested-object/35849>\
**Category:** Elasticsearch\
**Created:** [November 30, 2015, 1:38am UTC](https://discuss.elastic.co/t/transitioning-from-path-to-copy-to-with-extracting-field-nested-object/35849 "2015-11-30T01:38:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nemothekid](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nemothekid/32/6241_2.png) [@nemothekid](https://discuss.elastic.co/u/nemothekid)\
**Post date:** [November 30, 2015, 1:38am UTC](https://discuss.elastic.co/t/transitioning-from-path-to-copy-to-with-extracting-field-nested-object/35849/1 "2015-11-30T01:38:20Z")

</div>

Today I currently have a mapping like so:

```auto
conf = {
      "user": {
        "properties": {
          "id": {
            "type": "string",
            "index": "not_analyzed",
            "include_in_all": False
          },
          "created": {
            "type": "date",
            "include_in_all": False
          },
          "counts": {
            "type": "date",
            "path": "service.channel.stats.counts"
          }
}

```

It seems that with `copy_to` I would need to create all the objects up to `counts` in my mapping - or is there a simpler way?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 30, 2015, 2:45am UTC](https://discuss.elastic.co/t/transitioning-from-path-to-copy-to-with-extracting-field-nested-object/35849/2 "2015-11-30T02:45:00Z")

</div>

No.

Or yes. On the client side?

IMO copy\_to is the right thing to do.  
I don't think it's difficult. You will replace one line path by one line copy\_to.

---

<div class="post-metadata">

**Author:** ![nemothekid](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nemothekid/32/6241_2.png) [@nemothekid](https://discuss.elastic.co/u/nemothekid)\
**Post date:** [November 30, 2015, 3:01am UTC](https://discuss.elastic.co/t/transitioning-from-path-to-copy-to-with-extracting-field-nested-object/35849/3 "2015-11-30T03:01:08Z")

</div>

Right, during the creation of the mapping. The JSON I'm indexing is fixed at this point.

So there is no way other than create to nested objects for "service" then "channel", etc? To be clearer, my JSON object I'm going to index looks like this:

```auto
{
  "id":"aaa-bb-cc",
  "created":"yyyy-mm...",
  "service":{
     "other_fields":"...",
     "channel":{
         "other_fields":"...",
         "stats":{
             "counts":5,
             "other_fields":"...",
          }
      }
   }
}

```

And I want to be able to query ES (with query\_string) like so:

`created:{* TO 2012-01-01} counts:[0 to 100]`

Path is what worked in this case before (IIRC), and I'm just wondering if this sort of use case has a new method. Thanks for your help.

---

<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:** [July 5, 2017, 11:34pm UTC](https://discuss.elastic.co/t/transitioning-from-path-to-copy-to-with-extracting-field-nested-object/35849/4 "2017-07-05T23:34:59Z")

</div>


