Skip to content

Instantly share code, notes, and snippets.

@cwensel
Created February 15, 2013 19:12
Show Gist options
  • Select an option

  • Save cwensel/4962634 to your computer and use it in GitHub Desktop.

Select an option

Save cwensel/4962634 to your computer and use it in GitHub Desktop.
#!/bin/bash
curl -s -XPUT localhost:9200/_template/template_tags -d '{
"template" : "tags*",
"settings" : {
"index.analysis.analyzer.csv.type" : "pattern",
"index.analysis.analyzer.csv.pattern" : ","
},
"mappings" : {
"_default_" : {
"properties" : {
"tags" : {
"type" : "string",
"analyzer" : "csv",
"store" : "yes"
}
}
}
}
}'
echo
curl -s -XPUT 'localhost:9200/tags'
echo
for i in {0..200}
do
curl -s -XPUT "localhost:9200/tags/tag/$RANDOM" -d '{
"tags" : "a-b,a-b,a-c"
}'
done
curl -s -XPOST 'localhost:9200/_refresh'
echo
echo "query:"
curl -s -XPOST 'localhost:9200/tags/_search' -d '{
"facets" : {
"tags" : {
"terms" : {
"field" : "tags"
}
}
}
}'
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment