elasticsearch/elasticsearch — pull request #2387 by synhershko (2012-11-07 16:14:28+00:00)
Title: Highlighting percolator

I linked the percolator functionality with the Highlighting API, so you could percolate and get highlights as well (not just an ack). This added functionality is completely optional, and doesn't introduce performance hit if not used. I also verified compatibility with queries which were stored using the old API (highlight section on the Query document is completely optional).

For that to work, I changed HighlightingPhase to use a static method for the actual process, and changed the Matches response to a container class (PercolationMatch) instead of a simple string.

At this point highlighting works per query, that is - you would need to store the highlighting settings per query. A feature I'm likely to add to this soon is to have the ability to define global highlighting settings (when percolating).

Assumptions / gotchas:

* Assumes one document per percolation operation. Lucene.ExistsCollector is used which makes it possible for using more than one doc while percolating, but the rest of the API doesn't show like that is supported.
* Various REST responses were changed
* Works only with string fields. When you think of it, it does make sense...
* Some cleanup may be required