Skip to content

Instantly share code, notes, and snippets.

@lefloh
Created February 24, 2015 15:19
Show Gist options
  • Save lefloh/5131612b85a7528535b5 to your computer and use it in GitHub Desktop.
Save lefloh/5131612b85a7528535b5 to your computer and use it in GitHub Desktop.
Elasticsearch and unique indexes
# 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