Elasticsearch has ids query to find documents by id. I tried to use it in nested query:
{
"query": {
"nested": {
"path": "nestedField",
"query": {"ids":{ "values": ["nestedDocumentId" ] }},
"inner_hits" : {}
}
}
}
But this query looks at parent document id, not at nested.
Can I use ids query for finding nested documents by their ids?
The id of the nested documents is automatically created and you cannot control that.
The solution is to index that id
in the nested document itslef as regular field and do a terms
filter instead of ids
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With