Last active
June 23, 2017 15:22
-
-
Save wshirey/befeb196355d93b2cec0026a4eb67b10 to your computer and use it in GitHub Desktop.
index alias per client example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# clear out any previous test data | |
DELETE test*/ | |
# create index 1 | |
POST test.1/test/1 | |
{ | |
"client_id": 9991 | |
} | |
# create index 2 | |
POST test.2/test/1 | |
{ | |
"client_id": 9991 | |
} | |
# neither index should have aliases | |
GET test*/_aliases | |
# add aliases | |
POST _aliases | |
{ | |
"actions": [ | |
{ | |
"add": { | |
"index": "test.2", | |
"alias": "test-update" | |
} | |
}, | |
{ | |
"add": { | |
"index": "test.1", | |
"alias": "test" | |
} | |
} | |
] | |
} | |
# test.1 => test, test.2 => test-update | |
GET test*/_aliases | |
# apply client index alias to test-update, since it gets associated to test.2 ultimately | |
POST _aliases | |
{ | |
"actions": [ | |
{ | |
"add": { | |
"index": "test-update", | |
"alias": "test-9991", | |
"filter": { | |
"term": { | |
"client_id": "9991" | |
} | |
} | |
} | |
} | |
] | |
} | |
# verify test-update has test-9991 alias applied | |
GET test*/_aliases | |
# swap the test alias from test.1 to test.2, and delete test.1 | |
POST _aliases | |
{ | |
"actions": [ | |
{ | |
"add": { | |
"index": "test.2", | |
"alias": "test" | |
} | |
}, | |
{ | |
"remove": { | |
"index": "test.2", | |
"alias": "test-update" | |
} | |
}, | |
{ | |
"remove_index": { | |
"index": "test.1" | |
} | |
} | |
] | |
} | |
# test.2 should have test and test-9991 alias | |
GET test*/_aliases |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment