Skip to content

Instantly share code, notes, and snippets.

@cvializ
Created May 9, 2014 16:38
Show Gist options
  • Save cvializ/0a494579e19e645ecd4a to your computer and use it in GitHub Desktop.
Save cvializ/0a494579e19e645ecd4a to your computer and use it in GitHub Desktop.
This shows what I believe to be a bug causing inconsistent results in ElasticSearch 1.1.1
# Elasticsearch version 1.1.1
# Create the accesscontrol index
curl -XPUT 'http://localhost:9200/accesscontrol/'
# Create the user groups and specify which computers
# they may view logs for
curl -XPUT 'http://localhost:9200/accesscontrol/group/intern' -d '{
"name" : "intern",
"hosts" : ["computer1"]
}'
curl -XPUT 'http://localhost:9200/accesscontrol/group/admin' -d '{
"name" : "admin",
"hosts" : ["computer1","computer2","computer3"]
}'
# This one should return the same results as the
# admin group
curl -XPUT localhost:9200/_template/admin_group -d '
{
"template" : "logstash-*",
"aliases" : {
"template-admin-{index}" : {
"filter" : {
"terms" : {
"host" : {
"index" : "accesscontrol",
"type" : "group",
"id" : "admin",
"path" : "hosts"
},
"_cache_key" : "template_admin_hosts"
}
}
}
}
}'
# Create the logstash index and add an example document.
# This should create an index alias from the template
curl -XPOST localhost:9200/logstash-2014.05.09/example -d '{
"message":"my sample data",
"@version":"1",
"@timestamp":"2014-05-09T16:25:45.613Z",
"type":"example",
"host":"computer1"
}'
# Create the logstash alias for admins
curl -XPOST 'http://localhost:9200/_aliases' -d '
{
"actions" : [
{
"add" : {
"index" : "logstash-2014.05.09",
"alias" : "admin-logstash-2014.05.09",
"filter": {
"terms" : {
"host" : {
"index" : "accesscontrol",
"type" : "group",
"id" : "admin",
"path" : "hosts"
},
"_cache_key" : "admin_hosts"
}
}
}
}
]
}'
# Returns {"took":2,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1,"max_score":1.0,"hits":[ ... ]}}
curl -XGET localhost:9200/logstash-2014.05.09/_search
# Returns {"took":2,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1,"max_score":1.0,"hits":[ ... ]}}
curl -XGET localhost:9200/admin-logstash-2014.05.09/_search
# I get {"took":1,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":0,"max_score":null,"hits":[]}}
# Even though it's the same filter as the manually-applied alias.
curl -XGET localhost:9200/template-admin-logstash-2014.05.09/_search
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment