Hi
I'm trying to do a nested query in combination with query on fields in the parent. But how do I figure out if a match hits the parent field in the same time as I get an inner hit?
Best regards
Jens Christiansen
Hi
I'm trying to do a nested query in combination with query on fields in the parent. But how do I figure out if a match hits the parent field in the same time as I get an inner hit?
Best regards
Jens Christiansen
You could use a bool query with a must clause that has two queries: the nested query and the query on the parent field. Only documents that match both queries will be returned as a hit.
GET my_index/_search
{
"query": {
"bool": {
"must": [
{
"nested": {
"path": "path_to_nested_doc",
"query": { YOUR_NESTED_QUERY }
}
},
{
YOUR_QUERY_ON_THE_PARENT_FIELD
}
]
}
}
}
Dear Abdon
Great
Thanks for your solution and nice to hear from you again.
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
© 2020. All Rights Reserved - Elasticsearch
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant logo are trademarks of the Apache Software Foundation in the United States and/or other countries.