When I use hasChildQuery,everything works OK.But when I add addHighlightedField()
method,it does not work.The following is my code:
TermsLookupQ
This is related to the bug specified in the git issue here .
The workaround as mentioned in the thread is to specify it in highlight_query
Example :
PUT test
{
"mappings": {
"my_parent": {
"_all": {
"store": true
}
},
"my_child": {
"_parent": {
"type": "my_parent"
}
}
}
}
PUT test/my_parent/1
{
"text": "This is a parent document"
}
PUT test/my_child/2?parent=1
{
"text": "This is a child document"
}
POST test/my_parent/_search
{
"query": {
"bool": {
"must": [
{
"has_child": {
"type": "my_child",
"query": {
"match": {
"text": "child document"
}
}
}
},
{
"match": {
"_all": "parent"
}
}
]
}
},
"highlight": {
"fields": {
"_all": {}
},
"highlight_query": {
"match": {
"_all": "parent"
}
}
}
}
Results :
{
"_index": "test",
"_type": "my_parent",
"_id": "1",
"_score": 1.016466,
"_source": {
"text": "This is a parent document"
},
"highlight": {
"_all": [
"This is a parent document "
]
}
}
In Java Client you should be able to achieve it via this api