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_r361471274
 
 

 ##########
 File path: 
lucene/highlighter/src/java/org/apache/lucene/search/uhighlight/LengthGoalBreakIterator.java
 ##########
 @@ -174,7 +175,48 @@ private int moveToBreak(int idx) { // precondition: idx 
is a known break
   // called at start of new Passage given first word start offset
   @Override
   public int preceding(int offset) {
-    return baseIter.preceding(offset); // no change needed
+    final int fragmentStart = Math.max(baseIter.preceding(offset), 0); // 
convert DONE to 0
+    fragmentEndFromPreceding = baseIter.following(fragmentStart);
 
 Review comment:
   I understand what `offset` param is and what `fragmentStart` is, and that 
the boundaries of each are in different universes that may or may not align.  
But I don't see why that matters here.  I claim the call to 
`baseIter.following(fragmentStart)` is guaranteed to be equal to 
`baseIter.following(offset)` _because_ fragmentStart is 
`baseIter.preceding(offset)`.  The argument to the breakIterator can be any 
arbitrary character offset; it needn't be an existing break of any kind.  FWIW 
I made the simple correction and tests pass.  If you insist there is a problem 
then can you present a failing test?

----------------------------------------------------------------
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]

Reply via email to