user1116589
user1116589

Reputation: 429

Not all results included with parent-child query

I'm trying to query ES (v. 2.2.0) and get child documents with their parents.

My Structure: post is a parent of campaignPost; campaignPost is a child of post.

And here is mapping for campaignPost: http://pastebin.com/iAaAzdp3

Now in my index I've got 20 posts and 10 campaignPosts mapped to 10 of existing posts. The problem is that I'm expecting 10 records in the result but I've got only 4! Here is how I query ES: http://pastebin.com/1vWwbMA2

Thanks for any suggestions!

Upvotes: 1

Views: 53

Answers (1)

4the3eam
4the3eam

Reputation: 194

I had a similiar problem with parent child relationship where my child type was parent of another type. Problem relied on routing parameter what was unsuitable for my granchildren. According to ES documentation my _routing parameter had to point on grandfather type. The parent parameter is used to link the children with its parent, but the routing parameter ensures that it is stored on the same shard as its parent and grandparent. The routing value needs to be provided for all single-document requests.

Try to set your _routing parameter properly and let me know if it helps.

Upvotes: 1

Related Questions