I have a parent-child relationship. I'm able to search out the parent using "has_child" filter or query. Question is how can I get the highlight from the child?
Thanks
I have a parent-child relationship. I'm able to search out the parent using "has_child" filter or query. Question is how can I get the highlight from the child?
Thanks
Use "inner hits", read about it here: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-inner-hits.html
Thanks Maxim. It works beautifully. I'm not sure any performance implication though.
Hi.
Could you please share your "highlight" -section ? I need highlights on inner_hits as well... but in my case I'm using nested objects instead of a parent-child relationship. Thx.
Cheers, Henning.
Here you are. This is for parent-child and you can modify it for nested.
{
"_source": false,
"query": {
"bool": {
"should": [
{
"has_child": {
"type": "extension",
"query": {
"match": {
"_all": "united"
}
},
"inner_hits": {
"_source": false,
"highlight": {
"fields": {
"*": { }
}
}
}
}
},
{
"match": {
"_all": "Nancy"
}
}
]
}
},
"highlight": {
"fields": {
"*": { }
}
}
}
© 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.