Skip to content

Instantly share code, notes, and snippets.

@outoftime
Created February 16, 2012 16:23
Show Gist options
  • Save outoftime/1846196 to your computer and use it in GitHub Desktop.
Save outoftime/1846196 to your computer and use it in GitHub Desktop.
Reduction: top_children query returns no results when child field has the same name as a nested field as a nested field in the parent mapping
curl -XDELETE localhost:9200/test?pretty=true
echo ""
curl -XPUT localhost:9200/test?pretty=true
echo ""
curl -XPUT localhost:9200/test/parent/_mapping?pretty=true -d '{"parent":{"properties":{"name":{"type":"string","index":"analyzed"},"notes":{"properties":{"body":{"type":"string"}}}}}}'
echo ""
curl -XPUT localhost:9200/test/child/_mapping?pretty=true -d '{"child":{"_parent":{"type":"parent"}, "properties":{"body":{"type":"string","index":"analyzed"}}}}'
echo ""
curl -XPUT localhost:9200/test/parent/1?pretty=true -d "{\"name\":\"parent document\"}"
echo ""
curl -XPOST 'localhost:9200/test/child/_create?parent=1&pretty=true&refresh=true' -d '{"body":"pizza monster"}'
echo ""
curl -XGET localhost:9200/test/parent/_search?pretty=true -d '{"query":{"top_children":{"type":"child","query":{"query_string":{"query":"pizza monster","fields":["body"]}}}}}'
echo ""
curl -XGET localhost:9200/test/parent/_search?pretty=true -d '{"query":{"has_child":{"type":"child","query":{"query_string":{"query":"pizza monster","fields":["body"]}}}}}'
echo ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment