Having grandchildren in index with multiple shards

Hi,

I have following relation in mapping grandparent -> parent -> children.

Currently, queries work but if the number of shards is increased to 5 (from 1) then the query below is not returning all result.

{
"query": {
    "has_child": {
      "type": "parent",
      "query": {
        "has_child": {
          "type": "children",
          "query": {
            "match_all": {}
          }
        }
      }
    }
  }
}

Can the reason be something related to routing?

Thanks,

1 Like

if you have grandparents/parents & children you have to make sure that all those documents from one grandparent are on the same shard. This is done by setting the routing to the id of the grandparent for all of those documents.

Hope this helps!

1 Like

First of all thank you for your quick response.

Currently, children have routing ids to their parents and they have routing to the grandparents.

So, only grandparents doesn't have routing.

What am I probably missing?

All documents (parents and children) must be routed based on the grandparent as all documents in the hierarchy must end up in the same shard.

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.