Skip to content

Instantly share code, notes, and snippets.

@imotov
Created January 18, 2013 21:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save imotov/4568750 to your computer and use it in GitHub Desktop.
Save imotov/4568750 to your computer and use it in GitHub Desktop.
curl -XDELETE localhost:9200/test-idx
curl -XPUT localhost:9200/test-idx -d '{
"settings": {
"index.number_of_shards": 1,
"index.number_of_replicas": 0
},
"mappings": {
"doc": {
"properties": {
"foo": {"type": "string", "index": "not_analyzed"},
"bar": {"type": "string", "index": "not_analyzed"}
}
}
}
}'
curl -XPOST localhost:9200/test-idx/doc -d '{"foo": "1", "bar": "A"}'
curl -XPOST localhost:9200/test-idx/doc -d '{"foo": "2", "bar": "A"}'
curl -XPOST localhost:9200/test-idx/doc -d '{"foo": "1", "bar": "B"}'
curl -XPOST localhost:9200/test-idx/doc -d '{"foo": "2", "bar": "B"}'
curl -XPOST localhost:9200/_refresh
echo
curl "localhost:9200/test-idx/doc/_search?pretty=true&search_type=count" -d '{
"facets": {
"test": {
"terms": {
"script": {
"script_field" : "doc[\"foo\"].value+\"-\"+doc[\"bar\"].value"
}
}
}
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment