mirror of https://github.com/apache/lucene.git
LUCENE-3697: SimpleBoundaryScanner does not work well when highlighting at the beginning of the text
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1232769 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ff5b709b3a
commit
3150fae20d
|
@ -189,6 +189,9 @@ Bug Fixes
|
|||
* LUCENE-3686: CategoryEnhancement must override Object.equals(Object).
|
||||
(Sivan Yogev via Shai Erera)
|
||||
|
||||
* LUCENE-3697: SimpleBoundaryScanner does not work well when highlighting
|
||||
at the beginning of the text. (Shay Banon via Koji Sekiguchi)
|
||||
|
||||
Documentation
|
||||
|
||||
* LUCENE-3599: Javadocs for DistanceUtils.haversine() were incorrectly
|
||||
|
|
|
@ -61,6 +61,10 @@ public class SimpleBoundaryScanner implements BoundaryScanner {
|
|||
if( boundaryChars.contains( buffer.charAt( offset - 1 ) ) ) return offset;
|
||||
offset--;
|
||||
}
|
||||
// if we scanned up to the start of the text, return it, its a "boundary"
|
||||
if (offset == 0) {
|
||||
return 0;
|
||||
}
|
||||
// not found
|
||||
return start;
|
||||
}
|
||||
|
|
|
@ -36,6 +36,10 @@ public class SimpleBoundaryScannerTest extends LuceneTestCase {
|
|||
start = TEXT.indexOf("formance");
|
||||
int expected = TEXT.indexOf("high-performance");
|
||||
assertEquals(expected, scanner.findStartOffset(text, start));
|
||||
|
||||
start = TEXT.indexOf("che");
|
||||
expected = TEXT.indexOf("Apache");
|
||||
assertEquals(expected, scanner.findStartOffset(text, start));
|
||||
}
|
||||
|
||||
public void testFindEndOffset() throws Exception {
|
||||
|
|
|
@ -173,6 +173,6 @@ public class SimpleFragmentsBuilderTest extends AbstractTestCase {
|
|||
FieldFragList ffl = sflb.createFieldFragList( fpl, 100 );
|
||||
SimpleFragmentsBuilder sfb = new SimpleFragmentsBuilder();
|
||||
sfb.setMultiValuedSeparator( '/' );
|
||||
assertEquals( " b c//<b>d</b> e", sfb.createFragment( reader, 0, F, ffl ) );
|
||||
assertEquals( "//a b c//<b>d</b> e", sfb.createFragment( reader, 0, F, ffl ) );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue