diff --git a/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/lowlevel/docvalues/impl/JoiningTextMultiValuesSource.java b/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/lowlevel/docvalues/impl/JoiningTextMultiValuesSource.java index 2331c743e2e..e151d7d36c7 100644 --- a/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/lowlevel/docvalues/impl/JoiningTextMultiValuesSource.java +++ b/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/lowlevel/docvalues/impl/JoiningTextMultiValuesSource.java @@ -35,7 +35,7 @@ public static JoiningTextMultiValuesSource fromField(String field, NestedDocsPro protected final NestedDocsProvider nestedDocsProvider; - public JoiningTextMultiValuesSource(NestedDocsProvider nestedDocsProvider) { + protected JoiningTextMultiValuesSource(NestedDocsProvider nestedDocsProvider) { this.nestedDocsProvider = nestedDocsProvider; } @@ -84,15 +84,12 @@ public boolean advanceExact(int parentDoc) throws IOException { return hasNextValue(); } - currentParentDoc = parentDoc; - nextOrd = NO_MORE_ORDS; // To be set in the next call to hasNextValue() - return childDocsWithValues.advanceExactParent( parentDoc ); } @Override public boolean hasNextValue() throws IOException { - if ( nextOrd != NO_MORE_ORDS ) { + if ( super.hasNextValue() ) { return true; } @@ -101,7 +98,6 @@ public boolean hasNextValue() throws IOException { return true; } else { - nextOrd = NO_MORE_ORDS; return false; } } diff --git a/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/lowlevel/docvalues/impl/TextMultiValues.java b/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/lowlevel/docvalues/impl/TextMultiValues.java index a7d171185cd..dea3b339609 100644 --- a/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/lowlevel/docvalues/impl/TextMultiValues.java +++ b/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/lowlevel/docvalues/impl/TextMultiValues.java @@ -22,8 +22,6 @@ */ public abstract class TextMultiValues { - protected static final long NO_MORE_ORDS = -1L; - /** * Sole constructor. (For invocation by subclass * constructors, typically implicit.) @@ -91,6 +89,8 @@ protected static class DocValuesTextMultiValues extends TextMultiValues { protected final SortedSetDocValues values; protected long nextOrd; + protected int docValueCount = 0; + protected int nextOrdIndex = 0; DocValuesTextMultiValues(SortedSetDocValues values) { this.values = values; @@ -99,20 +99,28 @@ protected static class DocValuesTextMultiValues extends TextMultiValues { @Override public boolean advanceExact(int doc) throws IOException { boolean found = values.advanceExact( doc ); - nextOrd = found ? values.nextOrd() : NO_MORE_ORDS; + if ( found ) { + nextOrd = values.nextOrd(); + docValueCount = values.docValueCount(); + } + else { + docValueCount = 0; + } + nextOrdIndex = 0; return found; } @Override public boolean hasNextValue() throws IOException { - return nextOrd != NO_MORE_ORDS; + return nextOrdIndex < docValueCount; } @Override public long nextOrd() throws IOException { - long result = nextOrd; + nextOrdIndex++; + long previousOrd = nextOrd; nextOrd = values.nextOrd(); - return result; + return previousOrd; } @Override