Skip to content

Instantly share code, notes, and snippets.

@martijnvg
Created February 13, 2013 09:19
Show Gist options
  • Save martijnvg/4943265 to your computer and use it in GitHub Desktop.
Save martijnvg/4943265 to your computer and use it in GitHub Desktop.
Term facet with a pattern analyzed field
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
curl -s -XPUT 'localhost:9200/tags/tag/1' -d '{
"tags" : "a-b,a-b,a-c"
}'
curl -s -XPOST 'localhost:9200/_refresh'
echo
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