Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix percolator highlight sub fetch phase to not highlight query twice #26622

Merged
merged 2 commits into from
Sep 14, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@
* Highlighting in the case of the percolate query is a bit different, because the PercolateQuery itself doesn't get highlighted,
* but the source of the PercolateQuery gets highlighted by each hit containing a query.
*/
final class PercolatorHighlightSubFetchPhase extends HighlightPhase {
final class PercolatorHighlightSubFetchPhase implements FetchSubPhase {
private final HighlightPhase highlightPhase;

PercolatorHighlightSubFetchPhase(Settings settings, Map<String, Highlighter> highlighters) {
super(settings, highlighters);
this.highlightPhase = new HighlightPhase(settings, highlighters);
}


boolean hitsExecutionNeeded(SearchContext context) { // for testing
return context.highlight() != null && locatePercolatorQuery(context.query()).isEmpty() == false;
}
Expand Down Expand Up @@ -109,7 +109,7 @@ public void hitsExecute(SearchContext context, SearchHit[] hits) throws IOExcept
percolatorLeafReaderContext, slot, percolatorIndexSearcher
);
hitContext.cache().clear();
super.hitExecute(subSearchContext, hitContext);
highlightPhase.hitExecute(subSearchContext, hitContext);
for (Map.Entry<String, HighlightField> entry : hitContext.hit().getHighlightFields().entrySet()) {
if (percolateQuery.getDocuments().size() == 1) {
String hlFieldName;
Expand Down