gsmiller commented on code in PR #11950: URL: https://github.com/apache/lucene/pull/11950#discussion_r1029470218
########## 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: Right, that's a better approach. Thanks for the suggestion. I work on a codebase that forbids loading doc-values directly from a `LeafReader` (enforcing going through `DocValues`) as a safeguard to dealing with the null references returned by a reader. So I'm in a habit of using the `DocValues` factory methods (and checking `FieldInfo` if _really_ needing to see if the field exists in a segment). I'll simplify this. -- 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