Created
February 24, 2015 15:19
-
-
Save lefloh/5131612b85a7528535b5 to your computer and use it in GitHub Desktop.
Elasticsearch and unique indexes
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
# create two indexes | |
curl -XPUT 'http://docker:9200/idx-1/user/1' -d '{ | |
"name" : "John Doe" | |
}' | |
curl -XPUT 'http://docker:9200/idx-2/user/1' -d '{ | |
"name" : "Jane Doe" | |
}' | |
# add the same alias to bot of them | |
curl -XPOST 'docker:9200/_aliases' -d '{ | |
"actions": [ | |
{ "add": { | |
"alias": "my_alias", | |
"index": "idx-1" | |
}} | |
] | |
}' | |
curl -XPOST 'docker:9200/_aliases' -d '{ | |
"actions": [ | |
{ "add": { | |
"alias": "my_alias", | |
"index": "idx-2" | |
}} | |
] | |
}' | |
# considering that deletion of the old index failed: you'll get two documents | |
curl -XPOST "http://docker:9200/my_alias/user/_search" -d' { | |
"query": { | |
"match_all": {} | |
} | |
}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment