Skip to content

Instantly share code, notes, and snippets.

@jettro
Created March 13, 2014 10:41
Show Gist options
  • Save jettro/9525999 to your computer and use it in GitHub Desktop.
Save jettro/9525999 to your computer and use it in GitHub Desktop.
Checking filtered query
curl -XDELETE "http://localhost:9200/test_max_expansions"
curl -XPUT 'http://localhost:9200/test_max_expansions' -d '
{
"settings": {
"number_of_replicas": 0,
"number_of_shards": 1
},
"mappings": {
"posts" : {
"properties" : {
"title" : {"type" : "string"},
"hidden" : {"type" : "boolean"}
}
}
}
}'
for i in {1..1000}; do curl -XPUT "http://localhost:9200/test_max_expansions/posts/$i" -d "{\"title\" : \"a$i\", \"hidden\" : false}"; done
curl -XPUT 'http://localhost:9200/test_max_expansions/posts/1001' -d '
{
"title" : "a1001",
"hidden" : true
}'
curl -XPUT 'http://localhost:9200/test_max_expansions/posts/1002' -d '
{
"title" : "a1002",
"hidden" : true
}'
# This does not return results
curl -XGET 'http://localhost:9200/test_max_expansions/_search' -d '
{
"query": {
"filtered": {
"filter": {
"term": {
"hidden": true
}
},
"query": {
"match_phrase_prefix": {
"title": {
"query": "a1",
"max_expansions":10
}
}
}
}
}
}'
# This query does give results, the only difference is the max_expansions
curl -XGET 'http://localhost:9200/test_max_expansions/_search' -d '
{
"query": {
"filtered": {
"filter": {
"term": {
"hidden": true
}
},
"query": {
"match_phrase_prefix": {
"title": {
"query": "a1",
"max_expansions":500
}
}
}
}
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment