Hi Rukshan Very nicely laid out question. Thanks for providing all of the steps.
I agree that it doesn't work and (at least according to the docs) it should, so I've opened an issue here: https://github.com/elasticsearch/elasticsearch/issues/5399 Curiously, performing the same lookup using a `has_parent` query does work: POST /myindex/GrandChild/_search { "query": { "has_parent": { "parent_type": "Child", "query": { "filtered": { "filter": { "term": { "_id": "bob" } } } } } } } Clint On 11 March 2014 20:20, Rukshan Perera <[email protected]> wrote: > Hello, > > I have uploaded curl scripts to gist > https://gist.github.com/rukshanperera/9492610. > > I have a three level parent/child types as shown in the following mappings > > { "Parent" : > { > "properties" : { > "name" : { > "type" :"string", > "index":"analyzed" > } > } > } > } > > { > "Child" :{ > "_parent": { > "type": "Parent" > }, > "properties" : { > "name" : { > "type" :"string", > "index":"analyzed" > } > } > } > } > > > { > "GrandChild" :{ > "_parent": { > "type": "Child" > }, > "properties" : { > "name" : { > "type" :"string", > "index":"analyzed" > } > } > } > } > > > I want to search for *GrandChild *documents based on its parent id (which > is the id of a Child in this example). I used the following query but it > does not return any hits. ( "bob" - id of *Child *document. "alice" - id > of *Parent *document) > > curl -s -XPOST > "http://localhost:9200/myindex/GrandChild/_search?routing=alice" -d ' > { > "query" : { > "term" : { "_parent" : "bob" } > } > }' > > > However, I was able to get *Child *documents based on *Parent *id using > the following ( "alice" - id of *Parent *document) > > curl -s -XPOST "http://localhost:9200/myindex/Child/_search?routing=alice" -d > ' > { > "query" : { > "term" : { "_parent" : "alice" } > } > > } > > > Can someone please help me to get the first query working? > > Thanks, > Rukshan > > > > -- > You received this message because you are subscribed to the Google Groups > "elasticsearch" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/elasticsearch/5619eff7-b267-429b-afc3-e4c41aedc76b%40googlegroups.com<https://groups.google.com/d/msgid/elasticsearch/5619eff7-b267-429b-afc3-e4c41aedc76b%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "elasticsearch" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAPt3XKQ5uOmhddsLBr%3D7hb%2BbMKGMtGng-FiyGUW3ps3%2B0UCtBA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
