dsmiley commented on a change in pull request #1123: LUCENE-9093: Unified
highlighter with word separator never gives context to the left
URL: https://github.com/apache/lucene-solr/pull/1123#discussion_r361476978
##########
File path:
lucene/highlighter/src/java/org/apache/lucene/search/uhighlight/FieldHighlighter.java
##########
@@ -159,8 +160,9 @@ public Object highlightFieldForDoc(LeafReader reader, int
docId, String content)
break;
}
// advance breakIterator
- passage.setStartOffset(Math.max(this.breakIterator.preceding(start +
1), 0));
- passage.setEndOffset(Math.min(this.breakIterator.following(start),
contentLength));
+ passage.setStartOffset(Math.max(this.breakIterator.preceding(start +
1), lastPassageEnd));
+ lastPassageEnd = Math.min(this.breakIterator.following(start),
contentLength);
Review comment:
What I'm about to propose is perhaps technically out of scope but can you
please call `following` with the variable `end` minus 1?
Do you think we might need to guard the passage end offset by ensuring it is
> the start offset? start might theoretically be before lastPassageEnd I
think; if it wasn't possible then you wouldn't have guarded that with
`max(...,lastPassageEnd)`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]