davedash/elasticutils — pull request #15 by erikrose (2011-11-18 10:41:12+00:00)
Title: Highlighting and excerpting

Will: r?

It turns out passing the search result into excerpt() is insufficient, because in ES, we need the original 'highlight' hash key from the raw results, not the field content from the found document to throw at some BuildExcerpt analogue. There's no wonderful way of matching up a result object with a raw results entry after the fact, short of scanning through for equal document IDs (which may not be in the result object in the case of dict-style or list-style results). So instead, I simply(?) annotate the result objects with their highlights hash when we first make them. To allow this, I have to wrap the lists and dicts in a dummy new-style class, but instance() and everything else but type() and __class__ are maintained, so I don't think it'll break anything.