Updating document mapping without re-indexing

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 ?

No, only new data.

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

1 Like

updating existing docs means ?

Make a change to it.

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

could you please explain me clearly

If you have indexed:

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

Then send again:

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

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

1 Like

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?

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

Okay Thanks for your help !

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 ?

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

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

Edit your question, format your code there and be patient.