Skip to content

Instantly share code, notes, and snippets.

@imotov
Created December 3, 2012 16:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imotov/4196323 to your computer and use it in GitHub Desktop.
Save imotov/4196323 to your computer and use it in GitHub Desktop.
curl -XDELETE http://localhost:9200/test-idx
echo
curl -XPUT http://localhost:9200/test-idx -d '{
"settings" : {
"index" : {
"number_of_shards" : 1,
"number_of_replicas" : 0
}
},
"mappings" : {
"rec" : {
"_source" : { "enabled" : false },
"properties" : {
"color": { "type": "string", "store": "yes"}
}
}
}
}'
echo
curl -XPUT http://localhost:9200/test-idx/rec/1 -d '{
"color": "red"
}'
echo
curl -XPUT http://localhost:9200/test-idx/rec/2 -d '{
"color": "blue"
}'
echo
curl -XPUT http://localhost:9200/test-idx/rec/3 -d '{
"color": "blue"
}'
echo
curl -XPOST http://localhost:9200/test-idx/_refresh
echo
curl -XGET 'http://localhost:9200/test-idx/rec/_search?pretty=true&search_type=count' -d '{
"query": {
"query_string": {
"query": "*:*"
}
},
"facets": {
"facet1": {
"script": {
"map_script": "facet[_fields[field].value] += 1",
"lang": "javascript",
"params" : {
"facet" : {},
"field" : "color"
}
}
}
}
}
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment