Use Case: Let's say, you already have an index on one Server1 and you want to create a new index with the exact structure on Server2. What you should do?
Solution:
1. Copy the index structure from Server1. Let's say your index name is: product-data-index and you can access the settings here: https://x.x.x.x:9200/product-data-index/_settings
{
"product-data-index": {
"settings": {
"index": {
"routing": {
"allocation": {
"include": {
"_tier_preference": "data_content"
}
}
},
"number_of_shards": "5",
"provided_name": "product-data-index",
"max_result_window": "30000",
"creation_date": "1627383249968",
"analysis": {
"normalizer": {
"lowercaseNorm": {
"filter": [
"lowercase",
"asciifolding"
],
"type": "custom"
}
},
"analyzer": {
"comma_analyzer": {
"filter": [
"lowercase"
],
"pattern": "(,)",
"type": "pattern",
"tokenizer": "standard"
}
}
},
"number_of_replicas": "1",
"uuid": "cftuOgIPSKWONmbqfICH0w",
"version": {
"created": "7060299"
}
}
}
}
}
Copy this settings JSON
2. Clean the settings JSON.
Now before creating an index, you have to remove few fields from the above JSON
"product-data-index"
"uuid"
"version"
"creation_date"
and it should look like this.
{
"settings": {
"index": {
"routing": {
"allocation": {
"include": {
"_tier_preference": "data_content"
}
}
},
"number_of_shards": "5",
"max_result_window": "30000",
"analysis": {
"normalizer": {
"lowercaseNorm": {
"filter": [
"lowercase",
"asciifolding"
],
"type": "custom"
}
},
"analyzer": {
"comma_analyzer": {
"filter": [
"lowercase"
],
"pattern": "(,)",
"type": "pattern",
"tokenizer": "standard"
}
}
},
"number_of_replicas": "1"
}
}
}
}
3. Run this command on Server2 in postman as per the screenshot. You can use any other API Client
which can help you to create the index. You can also use curl.
That's it.
NOTE: To copy data from Server1 to Server2, you can use Reindex API
Thanks!!! Enjoy Programming :)
Comments
Post a Comment
Thanks for your valuable comments.