Skip to content

Instantly share code, notes, and snippets.

@imotov
Created February 13, 2013 22:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imotov/4948908 to your computer and use it in GitHub Desktop.
Save imotov/4948908 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
}
}'
echo
for i in {1..10}; do curl -XPUT localhost:9200/test/doc/$i -d "{\"foo\":\"bar\", \"doc\":\"$i\"}"; done
echo
curl -XPOST localhost:9200/test/_refresh
echo
curl localhost:9200/test/doc/_search -d '{
"query":{
"filtered":{
"query": {
"constant_score" : {
"filter" : {
"script" : {
"script" : "System.out.println(\"filter \" + doc.doc.value); doc.doc.value == 5 || doc.doc.value == 7",
"_cache": true
}
}
}
},
"filter": {
"terms" : {"doc": [5, 7]}
}
}
}
}'
echo
curl localhost:9200/test/doc/_search -d '{
"query":{
"filtered":{
"query": {
"constant_score" : {
"filter" : {
"script" : {
"script" : "System.out.println(\"filter \" + doc.doc.value); doc.doc.value == 5 || doc.doc.value == 7",
"_cache": true
}
}
}
},
"filter": {
"terms" : {"doc": [5, 7]}
}
}
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment