# Updating document mapping without re-indexing

**URL:** <https://discuss.elastic.co/t/updating-document-mapping-without-re-indexing/63466>\
**Category:** Elasticsearch\
**Created:** [October 20, 2016, 6:20am UTC](https://discuss.elastic.co/t/updating-document-mapping-without-re-indexing/63466 "2016-10-20T06:20:16Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![banu](https://avatars.discourse-cdn.com/v4/letter/b/2acd7d/32.png) [@banu](https://discuss.elastic.co/u/banu)\
**Post date:** [October 20, 2016, 6:20am UTC](https://discuss.elastic.co/t/updating-document-mapping-without-re-indexing/63466/1 "2016-10-20T06:20:16Z")

</div>

I am trying to add copy\_to for the existing index. For Ex:

PUT /my\_index

{ "mappings":{ "my\_type":{ "properties":{ "user\_name":{ "type":"string", "copy\_to":["key"], "index":"not\_analyzed", "include\_in\_all":false } } }, "key":{ "type":"string", "store":"yes" } } }

I have the data already in the user\_name. When updating the mapping will these data gets copied to the copy\_to field ? When i index new set of inputs will the new inputs only gets copied to the copy\_to (key) field ? Or do we need to do re-index to get the changes reflected ? How to update copy to without re-indexing the whole document or can we update only the specific user\_name document to get the changes reflected ?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [October 20, 2016, 6:32am UTC](https://discuss.elastic.co/t/updating-document-mapping-without-re-indexing/63466/2 "2016-10-20T06:32:38Z")

</div>

> [@banu](#):
>
> I have the data already in the user\_name. When updating the mapping will these data gets copied to the copy\_to field

No, only new data.

You need to reindex, or just issue a update to the existing docs.

---

<div class="post-metadata">

**Author:** ![banu](https://avatars.discourse-cdn.com/v4/letter/b/2acd7d/32.png) [@banu](https://discuss.elastic.co/u/banu)\
**Post date:** [October 20, 2016, 7:14am UTC](https://discuss.elastic.co/t/updating-document-mapping-without-re-indexing/63466/3 "2016-10-20T07:14:26Z")

</div>

updating existing docs means ?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [October 20, 2016, 7:26am UTC](https://discuss.elastic.co/t/updating-document-mapping-without-re-indexing/63466/4 "2016-10-20T07:26:32Z")

</div>

Make a change to it.

---

<div class="post-metadata">

**Author:** ![banu](https://avatars.discourse-cdn.com/v4/letter/b/2acd7d/32.png) [@banu](https://discuss.elastic.co/u/banu)\
**Post date:** [October 20, 2016, 7:28am UTC](https://discuss.elastic.co/t/updating-document-mapping-without-re-indexing/63466/5 "2016-10-20T07:28:40Z")

</div>

Do we need to update the existing documents values. Any API update you are mentioning ?

---

<div class="post-metadata">

**Author:** ![banu](https://avatars.discourse-cdn.com/v4/letter/b/2acd7d/32.png) [@banu](https://discuss.elastic.co/u/banu)\
**Post date:** [October 20, 2016, 7:59am UTC](https://discuss.elastic.co/t/updating-document-mapping-without-re-indexing/63466/6 "2016-10-20T07:59:23Z")

</div>

could you please explain me clearly

---

<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 20, 2016, 8:18am UTC](https://discuss.elastic.co/t/updating-document-mapping-without-re-indexing/63466/7 "2016-10-20T08:18:58Z")

</div>

If you have indexed:

```auto
PUT my_index/my_type/1
{
  "user_name": "bar"
}

```

Then send again:

```auto
PUT my_index/my_type/1
{
  "user_name": "bar"
}

```

Your document `1` will have its field copied to `key` field.

---

<div class="post-metadata">

**Author:** ![banu](https://avatars.discourse-cdn.com/v4/letter/b/2acd7d/32.png) [@banu](https://discuss.elastic.co/u/banu)\
**Post date:** [October 20, 2016, 9:03am UTC](https://discuss.elastic.co/t/updating-document-mapping-without-re-indexing/63466/8 "2016-10-20T09:03:32Z")

</div>

you mean we need to re index that specific document where we are using copy\_to  
without re indexing we cannot update the copy\_to field?

---

<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 20, 2016, 9:49am UTC](https://discuss.elastic.co/t/updating-document-mapping-without-re-indexing/63466/9 "2016-10-20T09:49:30Z")

</div>

Yes that's what @warkolm and I are saying.

---

<div class="post-metadata">

**Author:** ![banu](https://avatars.discourse-cdn.com/v4/letter/b/2acd7d/32.png) [@banu](https://discuss.elastic.co/u/banu)\
**Post date:** [October 20, 2016, 9:50am UTC](https://discuss.elastic.co/t/updating-document-mapping-without-re-indexing/63466/10 "2016-10-20T09:50:37Z")

</div>

Okay Thanks for your help !

---

<div class="post-metadata">

**Author:** ![banu](https://avatars.discourse-cdn.com/v4/letter/b/2acd7d/32.png) [@banu](https://discuss.elastic.co/u/banu)\
**Post date:** [October 20, 2016, 9:56am UTC](https://discuss.elastic.co/t/updating-document-mapping-without-re-indexing/63466/11 "2016-10-20T09:56:15Z")

</div>

i have another question. Can you please help on this  
I have 200K records and trying to fetch records based on certain match criteria ex: company\_name: "test" If i give size:250 expecting record is not available in search results. size:500 the expecting document is fetched and displayed. How to get the document in top 25 results ?

Query : {"explain":true,"size":250,"query":{"query\_string":{"query":" ( (NAME:"BANK AMERICA")^50 OR (ceoNames.fullCEOName:(BANK AMERICA))^30 OR (NAME\_PAIR:"BANK AMERICA")^30 OR (NORMAL\_NAME:(BANK AMERICA) AND CITY:"" ) ^40 OR (NORMAL\_NAME:(BANK AMERICA))^30 OR (tradeStyles.acronym:"BS")^5 OR (NORMAL\_NAME\_SOUNDEX:"BANK AMERICA")^5 OR (address.streetName:"" AND CITY:"")^30 OR (ZIP:"")^6 OR (address.streetName:"")^6 OR (address.streetNumber:"" AND address.streetName:"")^15 OR (telephones.telephone:"")^50 OR (mailAddresses.postbox:"")^6 ) "}},"sort":[{"\_score":{"order":"desc"}},{"statusIndicator":{"order":"asc"}}],"aggs":{"NAME":{"filter":{"term":{"NAME":"ATLS"}}}}}

I have a field 'max\_docs' based on that field i need to get the results. How to multiply max\_docs with the \_score field ?

---

<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 20, 2016, 10:12am UTC](https://discuss.elastic.co/t/updating-document-mapping-without-re-indexing/63466/12 "2016-10-20T10:12:11Z")

</div>

Please create a new thread for that and format your code using `</>` icon. It will make your post more readable.

---

<div class="post-metadata">

**Author:** ![banu](https://avatars.discourse-cdn.com/v4/letter/b/2acd7d/32.png) [@banu](https://discuss.elastic.co/u/banu)\
**Post date:** [October 20, 2016, 10:18am UTC](https://discuss.elastic.co/t/updating-document-mapping-without-re-indexing/63466/13 "2016-10-20T10:18:39Z")

</div>

I have already created a post but not getting any response. Please find the link [Elasticsearch query retrieve fetch expecting result in top 25 results](https://discuss.elastic.co/t/elasticsearch-query-retrieve-fetch-expecting-result-in-top-25-results/63474)

---

<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 20, 2016, 10:30am UTC](https://discuss.elastic.co/t/updating-document-mapping-without-re-indexing/63466/14 "2016-10-20T10:30:37Z")

</div>

Edit your question, format your code there and [be patient](https://discuss.elastic.co/t/about-the-elasticsearch-category/21).

---

<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, 10:10pm UTC](https://discuss.elastic.co/t/updating-document-mapping-without-re-indexing/63466/15 "2017-07-05T22:10:56Z")

</div>


