elasticsearch/elasticsearch — Issue #1471: Inner queries not resolved correctly in has_child filter
Author: outoftime
Created: 2011-11-15 22:21:52+00:00
State: open

Reduction ([download](http://pastie.org/pastes/2869261/text)):

curl -XDELETE 'localhost:9200/test?pretty=true'
echo
curl -XPOST 'localhost:9200/test?pretty=true' -d '{}'
echo
curl -XPOST 'localhost:9200/test/blog/_mapping?pretty=true' -d '{"blog":{"properties":{"name":{"type":"string"}}}}'
echo
curl -XPOST 'localhost:9200/test/post/_mapping?pretty=true' -d '{"post":{"_parent":{"type":"blog"},"properties":{"priority":{"type":"integer"}}}}'
echo
curl -XPUT 'localhost:9200/test/blog/1?refresh=true&pretty=true' -d '{"name":"Blog"}'
echo
curl -XPOST 'localhost:9200/test/post?parent=1&refresh=true&pretty=true' -d '{"priority":1}'
echo
curl -XPOST 'localhost:9200/test/post?parent=1&refresh=true&pretty=true' -d '{"priority":2}'
echo
echo "--- This correctly returns a document ---"
curl -XPOST 'localhost:9200/test/post/_search?pretty=true' -d '{"query":{"term":{"priority":2}}}'
echo
echo "--- This should return a document, but it doesn't ---"
curl -XPOST 'localhost:9200/test/blog/_search?pretty=true' -d '{"query":{"constant_score":{"filter":{"has_child":{"type":"post","query":{"term":{"priority":2}}}}}}}'
echo
echo "--- This correctly returns nothing ---"
curl -XPOST 'localhost:9200/test/post/_search?pretty=true' -d '{"query":{"range":{"priority":{"gt":5}}}}'
echo
echo "--- This should return nothing, but it returns something ---"
curl -XPOST 'localhost:9200/test/blog/_search?pretty=true' -d '{"query":{"constant_score":{"filter":{"has_child":{"type":"post","query":{"range":{"priority":{"gt":5}}}}}}}}'
echo