SOLR-13034: RTG sometimes didn't materialize LazyField (#2408)
Partial (AKA Atomic) updates could encounter "LazyField" instances in the document
cache and not know hot to deal with them when writing the updated doc to the update log.
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index f7397d6..5724064 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -260,8 +260,13 @@
Bug Fixes
---------------------
* SOLR-15078: Fix ExpandComponent behavior when expanding on numeric fields to differentiate '0' group from null group (hossman)
+
* SOLR-15149: Better exception handling for LTR model creation errors (Alessandro Benedetti, Christine Poerschke)
+* SOLR-13034: Partial (AKA Atomic) updates could encounter "LazyField" instances in the document
+ cache and not know hot to deal with them when writing the updated doc to the update log.
+ (David Smiley)
+
Other Changes
---------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java b/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java
index ad14837..c5751d3 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java
@@ -813,8 +813,9 @@
if ((!sf.hasDocValues() && !sf.stored()) || schema.isCopyFieldTarget(sf)) continue;
}
for (Object val: doc.getFieldValues(fname)) {
- if (val instanceof Field) {
- Field f = (Field) val;
+ if (val instanceof IndexableField) {
+ IndexableField f = (IndexableField) val;
+ // materialize:
if (sf != null) {
val = sf.getType().toObject(f); // object or external string?
} else {
diff --git a/solr/core/src/test/org/apache/solr/update/processor/AtomicUpdatesTest.java b/solr/core/src/test/org/apache/solr/update/processor/AtomicUpdatesTest.java
index 3eba208..fcedc1f 100644
--- a/solr/core/src/test/org/apache/solr/update/processor/AtomicUpdatesTest.java
+++ b/solr/core/src/test/org/apache/solr/update/processor/AtomicUpdatesTest.java
@@ -1005,7 +1005,11 @@
assertU(commit());
- assertQ(req("q", "cat:*", "indent", "true"), "//result[@numFound = '2']");
+ // note: by requesting only the id, the other field values will be LazyField instances in the
+ // document cache.
+ // This winds up testing that future fetches by RTG of this doc will handle it properly.
+ // See SOLR-13034
+ assertQ(req("q", "cat:*", "indent", "true", "fl", "id"), "//result[@numFound = '2']");
assertQ(req("q", "cat:bbb", "indent", "true"), "//result[@numFound = '0']");