# Retrieving Copy\_to/Stored fields

**URL:** <https://discuss.elastic.co/t/retrieving-copy-to-stored-fields/203948>\
**Category:** Elasticsearch\
**Created:** [October 17, 2019, 1:21am UTC](https://discuss.elastic.co/t/retrieving-copy-to-stored-fields/203948 "2019-10-17T01:21:27Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![vkandiva](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vkandiva/32/42845_2.png) [@vkandiva](https://discuss.elastic.co/u/vkandiva)\
**Post date:** [October 17, 2019, 1:21am UTC](https://discuss.elastic.co/t/retrieving-copy-to-stored-fields/203948/1 "2019-10-17T01:21:27Z")

</div>

I noticed that copy\_to fields work for aggregations but don't get show up in a Match all query or any similar query. Upon further searching I figured setting "store": true in the Field mappings should help but I still was not able to see them in searches.

This was the syntax I was trying to use:

```
GET index/_search
    {
      "stored_fields": [
        "CopyField"
      ],
      "query": {
        "match_all": {}
      }
    }

```

Am I missing something here?

---

<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:** [October 17, 2019, 5:23am UTC](https://discuss.elastic.co/t/retrieving-copy-to-stored-fields/203948/2 "2019-10-17T05:23:04Z")

</div>

Welcome!

Could you provide a full recreation script as described in [About the Elasticsearch category](https://discuss.elastic.co/t/about-the-elasticsearch-category/21). It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

A full reproduction script will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.

---

<div class="post-metadata">

**Author:** ![vkandiva](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vkandiva/32/42845_2.png) [@vkandiva](https://discuss.elastic.co/u/vkandiva)\
**Post date:** [October 17, 2019, 6:27am UTC](https://discuss.elastic.co/t/retrieving-copy-to-stored-fields/203948/3 "2019-10-17T06:27:28Z")

</div>

```
I had created a copy_to field as of an existing field by altering its mapping below:
{
  "properties": {
    "ExistingField": {
      "type": "date",
      "copy_to": "CopiedField"
    },
    "CopiedField": {
      "type": "date",
      "store": true
    }
  }
}

```

I had used "store": "true" since I wanted this new fields value to be retrieved when I do a search. Aggregations with the "CopiedField" work fine but when I try to search for a value in this new CopiedField I cannot see anything being retrieved:

```
{
  "stored_fields": [
      "CopiedField"
     ],
  "query": {
  "match_all": {}
  }
}

```

How do I retrieve the value of this "CopiedField" in a simple search?

---

<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:** [November 14, 2019, 6:27am UTC](https://discuss.elastic.co/t/retrieving-copy-to-stored-fields/203948/4 "2019-11-14T06:27:28Z")

</div>

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

---

<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 25, 2019, 10:14am UTC](https://discuss.elastic.co/t/retrieving-copy-to-stored-fields/203948/5 "2019-11-25T10:14:45Z")

</div>



---

<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 25, 2019, 10:15am UTC](https://discuss.elastic.co/t/retrieving-copy-to-stored-fields/203948/6 "2019-11-25T10:15:55Z")

</div>

Sorry it took time to answer.

I tried your example. Here a full script:

```auto
PUT index
{
  "mappings": {
    "properties": {
      "ExistingField": {
        "type": "date",
        "copy_to": "CopiedField"
      },
      "CopiedField": {
        "type": "date",
        "store": true
      }
    }
  }
}

PUT index/_doc/1
{
  "ExistingField": "2019-11-25"
}
GET index/_search
{
  "stored_fields": [
    "CopiedField"]
}

```

This gives:

```auto
{
  "took" : 2,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 1,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "index",
        "_type" : "_doc",
        "_id" : "1",
        "_score" : 1.0,
        "fields" : {
          "CopiedField" : [
            "2019-11-25T00:00:00.000Z"
          ]
        }
      }
    ]
  }
}

```

So everything looks fine on my side. I tested with 7.4.2.

---

<div class="post-metadata">

**Author:** ![vkandiva](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vkandiva/32/42845_2.png) [@vkandiva](https://discuss.elastic.co/u/vkandiva)\
**Post date:** [December 18, 2019, 12:31am UTC](https://discuss.elastic.co/t/retrieving-copy-to-stored-fields/203948/7 "2019-12-18T00:31:08Z")

</div>

After I update the mapping existing fields will not be updated and will come up blank. After new data is inserted in the indices it does come up in a search request.

---

<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:** [November 4, 2022, 7:29am UTC](https://discuss.elastic.co/t/retrieving-copy-to-stored-fields/203948/8 "2022-11-04T07:29:41Z")

</div>


