First off - awesome library.
Is there a way to highlight hits from nested queries? I don't see anything about it in the docs:
http://elasticsearch-dsl.readthedocs.io/en/latest/api.html#elasticsearch_dsl.Search.highlight
You can highlight things if you use the inner_hits option (0). Just pass inner_hits={"highlight": {"fields": {"nested_path.field": {}}}} to your nested query like so:
s = Search().query('nested', path='comments', query=Q('match', comments__content='python'), inner_hits={"highlight": {"fields": {"comments.content": {}}}})
for hit in s:
for comment in hit.meta.inner_hits.comments.hits:
# not 100% sure about the path, but look into comment.meta
for fragment in comment.meta.highlight['comment.content']:
print(fragment)
Hope this helps!
0 - https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-inner-hits.html#nested-inner-hits
Worked. Thank you!
Most helpful comment
You can highlight things if you use the
inner_hitsoption (0). Just passinner_hits={"highlight": {"fields": {"nested_path.field": {}}}}to yournestedquery like so:Hope this helps!
0 - https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-inner-hits.html#nested-inner-hits