Skip to content

Instantly share code, notes, and snippets.

@wshirey
Last active June 23, 2017 15:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wshirey/befeb196355d93b2cec0026a4eb67b10 to your computer and use it in GitHub Desktop.
Save wshirey/befeb196355d93b2cec0026a4eb67b10 to your computer and use it in GitHub Desktop.
index alias per client example
# 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