Is it possible to find which elasticsearch shard(s) a document is on?
In your query , you can enable explain flag and it will tell you where each of the documents are from which shard and node.You can find a sample query as follows -
{ "explain": true, "query": { "match_all": {} }}
Along with docID , index name and type name , it will also emit node ID and shard ID.
You can find samples on usage of explain API here.
To debug this you don't have to check shard and node identifiers at all.
All you have to do is make sure that _parent
and/or _routing
fields of the child documents match the id
of the parent document. Use /_search?pretty&fields=_parent,_routing&_source=true
to show these fields.
To find docs with a specific _routing
or _parent
id just use /_search?pretty&fields=_parent,_routing&_source=true&q=id:123 OR _routing:123 OR _parent:123
This will find parent docs and child docs.