Reindex cannot be used to merge two indices. Reindex does a complete update in the destination index.
Consider the below index my-new-index-000001:
GET my-new-index-000001/_doc/6
{
"_index" : "my-new-index-000001",
"_type" : "_doc",
"_id" : "6",
"_version" : 26,
"_seq_no" : 34,
"_primary_term" : 16,
"found" : true,
"_source" : {
"field2" : "value2",
"field1" : "value1"
}
}
The above index had two fields field1 and field2.
The below snippet is used to reindex a source field (new_field) to the destination:
# reindex that field
POST _reindex
{
"source": {
"index": ["my-index-000001"],
"query": {
"terms": {
"_id": [6]
}
},
"_source":["new_field"]
},
"dest": {
"index": "my-new-index-000001"
}
}
After reindexing this is the updated my-new-index-000001 index
GET my-new-index-000001/_doc/6
{
"_index" : "my-new-index-000001",
"_type" : "_doc",
"_id" : "6",
"_version" : 27,
"_seq_no" : 35,
"_primary_term" : 16,
"found" : true,
"_source" : {
"new_field" : false
}
}
Is there a way to do partial update in Elastic search from source to destination based on a common field? Is there a way to achieve this using python script. Please share a working snippet or reference.
you can use
Update By Query API
.https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update-by-query.html