Given two indexes test
and amazon
.
PUT /test/_doc/1
{
"customer_id" : "1234",
"customer_name" : "origin",
"farm_name": "Origin Delta"
}
PUT /amazon/_doc/2
{
"customer_id" : "1234",
"farm_name": "Origin Delta"
}
I want to merge these two indexes based on customer_id
.
Question: Is there a way to merge two indexes, test
and amazon
together such that amazon
index will have customer_name
field with the value "origin"?
Attempt 1:
POST /test,amazon/_forcemerge
POST /_forcemerge
GET /test,amazon/_search
output:
"hits" : [
{
"_index" : "amazon",
"_type" : "_doc",
"_id" : "2",
"_score" : 1.0,
"_source" : {
"customer_id" : "1234",
"farm_name" : "Origin Delta"
}
},
{
"_index" : "test",
"_type" : "_doc",
"_id" : "1",
"_score" : 1.0,
"_source" : {
"customer_id" : "1234",
"customer_name" : "origin",
"farm_name" : "Origin Delta"
}
}
]
Result Analysis:
- Attempt didn't work. I was expecting customer_name: "origin" to be added to the index amazon, but it didn't work.
Attempt 2:
POST _reindex
{
"source": {
"index": ["amazon", "test"]
},
"dest": {
"index": "new_amazon"
}
}
GET /new_amazon/_search
output:
"hits" : [
{
"_index" : "new_amazon",
"_type" : "_doc",
"_id" : "2",
"_score" : 1.0,
"_source" : {
"customer_id" : "1234",
"farm_name" : "Origin Delta"
}
},
{
"_index" : "new_amazon",
"_type" : "_doc",
"_id" : "1",
"_score" : 1.0,
"_source" : {
"customer_id" : "1234",
"customer_name" : "origin",
"farm_name" : "Origin Delta"
}
}
]
Result Analysis:
- Attempt didn't work. I was expecting customer_name: "origin" to be added to the index amazon, but it didn't work.