diff --git a/solr/core/src/java/org/apache/solr/search/SolrDocumentFetcher.java b/solr/core/src/java/org/apache/solr/search/SolrDocumentFetcher.java
index a04a0d0d59b..7693ee4ac75 100644
--- a/solr/core/src/java/org/apache/solr/search/SolrDocumentFetcher.java
+++ b/solr/core/src/java/org/apache/solr/search/SolrDocumentFetcher.java
@@ -899,6 +899,8 @@ public SortedNumericDocValues getSortedNumericDocValues(
dv = sndvs[leafOrd];
int currentDoc = dv.docID();
if (localId == currentDoc && !consumed[leafOrd]) {
+ consumed[leafOrd] = true;
+ noMatchSince[leafOrd] = DocIdSetIterator.NO_MORE_DOCS;
return dv;
} else if (localId <= currentDoc) {
if (localId >= noMatchSince[leafOrd]) {
@@ -949,6 +951,8 @@ public SortedSetDocValues getSortedSetDocValues(int localId, LeafReader leafRead
dv = ssdvs[leafOrd];
int currentDoc = dv.docID();
if (localId == currentDoc && !consumed[leafOrd]) {
+ consumed[leafOrd] = true;
+ noMatchSince[leafOrd] = DocIdSetIterator.NO_MORE_DOCS;
return dv;
} else if (localId <= currentDoc) {
if (localId >= noMatchSince[leafOrd]) {
diff --git a/solr/core/src/test/org/apache/solr/search/TestDocValuesIteratorCache.java b/solr/core/src/test/org/apache/solr/search/TestDocValuesIteratorCache.java
index 338be897c70..38f163833a5 100644
--- a/solr/core/src/test/org/apache/solr/search/TestDocValuesIteratorCache.java
+++ b/solr/core/src/test/org/apache/solr/search/TestDocValuesIteratorCache.java
@@ -20,7 +20,10 @@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
+import java.nio.file.StandardCopyOption;
import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
import java.util.Random;
import java.util.Set;
import org.apache.lucene.tests.util.LuceneTestCase;
@@ -60,27 +63,14 @@ protected void after() {
}
};
- private static String fieldConfig(String fieldName, boolean multivalued) {
- return "\n";
- }
-
- private static final String SINGLE = "single";
- private static final String MULTI = "multi";
-
@SuppressWarnings("try")
public void test() throws Exception {
Path configSet = LuceneTestCase.createTempDir();
SolrTestCaseJ4.copyMinConf(configSet.toFile());
- Path schemaXml = configSet.resolve("conf/schema.xml");
- Files.writeString(
- schemaXml,
- Files.readString(schemaXml)
- .replace(
- "", fieldConfig(SINGLE, false) + fieldConfig(MULTI, true) + ""));
+ Files.copy(
+ TEST_PATH().resolve("collection1/conf/schema-docValuesMulti.xml"),
+ configSet.resolve("conf/schema.xml"),
+ StandardCopyOption.REPLACE_EXISTING);
solrClientTestRule.newCollection().withConfigSet(configSet.toString()).create();
@@ -96,8 +86,8 @@ public void test() throws Exception {
SolrIndexSearcher s = sref.get();
assertEquals(DOC_COUNT, s.maxDoc());
SolrDocumentFetcher docFetcher = s.getDocFetcher();
- DocValuesIteratorCache dvIterCache = new DocValuesIteratorCache(s);
- final Set getFields = Set.of(SINGLE, MULTI);
+ Map dvIterCache = new HashMap<>();
+ final Set getFields = Set.of("stringdv");
final SolrDocument doc = new SolrDocument();
for (int i = DOC_COUNT * 10; i >= 0; i--) {
int checkId = r.nextInt(DOC_COUNT);
@@ -107,12 +97,10 @@ public void test() throws Exception {
if (expected == null) {
assertTrue(doc.isEmpty());
} else {
- assertEquals(2, doc.size());
- Object singleValue = doc.getFieldValue(SINGLE);
- Collection