Skip to content

Instantly share code, notes, and snippets.

@imotov
Created December 18, 2012 20:12
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/4331528 to your computer and use it in GitHub Desktop.
Save imotov/4331528 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 '{
"mappings": {
"article": {
"properties": {
"a": {
"type": "integer"
},
"b": {
"type": "nested",
"include_in_root": true,
"c": {
"type": "integer"
}
}
}
}
}
}
'
echo
curl -XPUT 'http://localhost:9200/test-idx/article/1' -d '{ "a": 1, b: [{"c": 1},{"c": 2}] }'
echo
curl -XPUT 'http://localhost:9200/test-idx/article/2' -d '{ "a": 1, b: [{"c": 2},{"c": 3}] }'
echo
curl -XPUT 'http://localhost:9200/test-idx/article/3' -d '{ "a": 2, b: [{"c": 1},{"c": 10}] }'
echo
curl -XPOST 'http://localhost:9200/test-idx/_refresh'
echo
curl -XGET 'http://localhost:9200/test-idx/article/_search?pretty=true&search_type=count' -d '{
"query" : { "match_all" : {} },
"facets": {
"test" : {
"terms_stats" : {
"key_field" : "a",
"value_field": "b.c"
}
}
}
}'
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment