Highlighting _all fields


(Arvind Kumar Chigurala) #1

I enabled store=true for my all fields. then I tried to highlight and I get below error. Please help

"can't load global ordinals for reader of type: class org.apache.lucene.search.highlight.WeightedSpanTermExtractor$DelegatingLeafReader must be a DirectoryReader"


(Mark Harwood) #2

I'm not sure what that error is but generally highlighting the _all field is not desirable.

The default for the highlighter is to highlight fields using only terms from the query that were explicitly targeted at those fields (so a search for forename:mark won't highlight any "mark" tokens found in a surname field).

However, when searching the all field this is precisely what you want to do - search one (indexed) field but highlight another (stored) field. Try set require_field_match to false.
See https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-highlighting.html#field-match3


(Arvind Kumar Chigurala) #3

I am searching for a phrase with in a whole document, so any field can be a match.

I need the highlighter to give me highlights for all fields where the match was.


(Nik Everett) #4

In that case you can try to highlight on "*" and set require_field_match to false.


(Arvind Kumar Chigurala) #5

When I try to highlight on *, I get ( i have set _all store=yes)

"can't load global ordinals for reader of type: class org.apache.lucene.search.highlight.WeightedSpanTermExtractor$DelegatingLeafReader must be a DirectoryReader"


(system) #6