Skip to content

Instantly share code, notes, and snippets.

@imotov
Created February 26, 2013 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save imotov/5041738 to your computer and use it in GitHub Desktop.
Save imotov/5041738 to your computer and use it in GitHub Desktop.
curl -XDELETE localhost:9200/test
curl -XPUT localhost:9200/test -d '{
"settings": {
"index.number_of_shards": 1,
"index.number_of_replicas": 0
},
"mappings": {
"doc": {
"_timestamp" : {"enabled" : true, "index" : "analyzed", "store" : "yes"}
}
}
}'
curl -XPUT localhost:9200/test/doc/1 -d '{"foo": ["1"]}'
curl -XPUT localhost:9200/test/doc/2 -d '{"foo": ["2", "3"]}'
curl -XPUT localhost:9200/test/doc/3 -d '{"foo": ["3", "4", "5"]}'
curl -XPOST localhost:9200/test/_refresh
echo
curl "localhost:9200/test/doc/_search" -d '{
"sort": [
{
"_script": {
"script" : "doc[\"foo\"].values.size()",
"type" : "number"
}
}
]
}'
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment