jpountz commented on code in PR #11950:
URL: https://github.com/apache/lucene/pull/11950#discussion_r1029197613


##########
lucene/core/src/java/org/apache/lucene/document/BinaryRangeFieldRangeQuery.java:
##########
@@ -91,7 +92,11 @@ public Query rewrite(IndexSearcher indexSearcher) throws 
IOException {
   }
 
   private BinaryRangeDocValues getValues(LeafReader reader, String field) 
throws IOException {
-    BinaryDocValues binaryDocValues = reader.getBinaryDocValues(field);
+    FieldInfo info = reader.getFieldInfos().fieldInfo(field);
+    if (info == null) {
+      return null;
+    }
+    BinaryDocValues binaryDocValues = DocValues.getBinary(reader, field);

Review Comment:
   I'm not sure I understand why we need to retrieve field infos, 
`getBinaryDocValues` already returns `null` when the field doesn't exist, so 
doing the following should be enough?
   
   ```
   BinaryDocValues binaryDocValues = reader.getBinaryDocValues(field);
   if (binaryDocValues == null) {
     return null;
   }
   return new BinaryRangeDocValues(binaryDocValues, numDims, 
numBytesPerDimension);
   ```



##########
lucene/CHANGES.txt:
##########
@@ -143,6 +143,9 @@ Bug Fixes
 
 * GITHUB#11907: Fix latent casting bugs in BKDWriter. (Ben Trent)
 
+* GITHUB#11950: Fix NPE in BinaryRangeFieldRangeQuery variants when the 
queried field doesn't exist
+  in a segment or is of the wrong type. (Greg Miller)

Review Comment:
   Is is true that there would be a NPE when the field is of the wrong type? I 
would have expected `CodecReader#getBinaryDocValues` to catch the problem?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to