pyes.highlight

class pyes.highlight.HighLighter(pre_tags=None, post_tags=None, fields=None, fragment_size=None, number_of_fragments=None, fragment_offset=None, encoder=None)

This object manage the highlighting

Parameters:
  • pre_tags – list of tags before the highlighted text. importance is ordered.. ex. ['<b>']
  • post_tags – list of end tags after the highlighted text. should line up with pre_tags. ex. ['</b>']
  • fields – list of fields to highlight
  • fragment_size – the size of the grament
  • number_or_fragments – the maximum number of fragments to return; if 0, then no fragments are returned and instead the entire field is returned and highlighted.
  • fragment_offset – controls the margin to highlight from

Use this with a pyes.query.Search like this:

h = HighLighter(['<b>'], ['</b>'])
s = Search(TermQuery('foo'), highlight=h)
add_field(name, fragment_size=150, number_of_fragments=3, fragment_offset=None, order='score', type=None)

Add a field to Highlinghter

serialize()