LUCENE-2616: FastVectorHighlighter: out of alignment when the first value is empty in multiValued field

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@989035 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Koji Sekiguchi 2010-08-25 12:04:05 +00:00
parent fcfa3ef727
commit 1238382bf4
3 changed files with 14 additions and 4 deletions

View File

@ -486,6 +486,9 @@ Bug fixes
can cause the same document to score to differently depending on
what segment it resides in. (yonik)
* LUCENE-2616: FastVectorHighlighter: out of alignment when the first value is
empty in multiValued field (Koji Sekiguchi)
New features
* LUCENE-2128: Parallelized fetching document frequencies during weight

View File

@ -155,9 +155,10 @@ public abstract class BaseFragmentsBuilder implements FragmentsBuilder {
protected String getFragmentSource( StringBuilder buffer, int[] index, String[] values,
int startOffset, int endOffset ){
while( buffer.length() < endOffset && index[0] < values.length ){
if( index[0] > 0 && values[index[0]].length() > 0 )
buffer.append( values[index[0]] );
if( values[index[0]].length() > 0 && index[0] + 1 < values.length )
buffer.append( multiValuedSeparator );
buffer.append( values[index[0]++] );
index[0]++;
}
int eo = buffer.length() < endOffset ? buffer.length() : endOffset;
return buffer.substring( startOffset, eo );
@ -166,9 +167,10 @@ public abstract class BaseFragmentsBuilder implements FragmentsBuilder {
protected String getFragmentSource( StringBuilder buffer, int[] index, Field[] values,
int startOffset, int endOffset ){
while( buffer.length() < endOffset && index[0] < values.length ){
if( index[0] > 0 && values[index[0]].isTokenized() && values[index[0]].stringValue().length() > 0 )
buffer.append( values[index[0]].stringValue() );
if( values[index[0]].isTokenized() && values[index[0]].stringValue().length() > 0 && index[0] + 1 < values.length )
buffer.append( multiValuedSeparator );
buffer.append( values[index[0]++].stringValue() );
index[0]++;
}
int eo = buffer.length() < endOffset ? buffer.length() : endOffset;
return buffer.substring( startOffset, eo );

View File

@ -60,6 +60,8 @@ public abstract class AbstractTestCase extends LuceneTestCase {
protected QueryParser paB;
protected static final String[] shortMVValues = {
"",
"",
"a b c",
"", // empty data in multi valued field
"d e"
@ -352,6 +354,9 @@ public abstract class AbstractTestCase extends LuceneTestCase {
}
protected void makeIndexShortMV() throws Exception {
// ""
// ""
// 012345
// "a b c"