jtibshirani commented on a change in pull request #749:
URL: https://github.com/apache/lucene/pull/749#discussion_r839809386



##########
File path: 
lucene/core/src/java/org/apache/lucene/search/SortedNumericSortField.java
##########
@@ -62,7 +62,9 @@ public SortedNumericSortField(String field, SortField.Type 
type) {
   }
 
   /**
-   * Creates a sort, possibly in reverse, by the minimum value in the set for 
the document.
+   * Creates a sort, possibly in reverse, by the minimum value in the set for 
the document. Please

Review comment:
       I don't think we should restrict what's supported here. I was only 
thinking we'd what sort types we apply the optimization for in 
`IndexSortSortedNumericDocValuesRangeQuery`, not make any restrictions for 
sorting in general.
   
   So we could move this comment about the sort types it can handle to 
`IndexSortSortedNumericDocValuesRangeQuery`.

##########
File path: lucene/CHANGES.txt
##########
@@ -39,7 +39,9 @@ Optimizations
 
 Bug Fixes
 ---------------------
-(No changes)
+
+* LUCENE-10466: IndexSortSortedNumericDocValuesRangeQuery unconditionally 

Review comment:
       Small comment, in the changelog we usually describe what the change 
does, as opposed to the bug statement (like "Ensure 
IndexSortSortedNumericDocValuesRangeQuery handles sort field types besides 
LONG")

##########
File path: 
lucene/sandbox/src/test/org/apache/lucene/sandbox/search/TestIndexSortSortedNumericDocValuesRangeQueryByType.java
##########
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.lucene.sandbox.search;
+
+import com.carrotsearch.randomizedtesting.generators.RandomPicks;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.SortedNumericDocValuesField;
+import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.Sort;
+import org.apache.lucene.search.SortField;
+import org.apache.lucene.search.SortedNumericSortField;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.tests.analysis.MockAnalyzer;
+import org.apache.lucene.tests.index.RandomIndexWriter;
+import org.apache.lucene.tests.util.LuceneTestCase;
+
+public class TestIndexSortSortedNumericDocValuesRangeQueryByType extends 
LuceneTestCase {

Review comment:
       It'd be good to fold these tests into 
`IndexSortSortedNumericDocValuesRangeQuery` so we just have one place where 
this query is tested.

##########
File path: 
lucene/sandbox/src/java/org/apache/lucene/sandbox/search/IndexSortSortedNumericDocValuesRangeQuery.java
##########
@@ -318,6 +326,17 @@ private static ValueComparator loadComparator(
     };
   }
 
+  private static Number convert(Type type, long topValue) {
+    if (type == Type.INT) {
+      return (int) topValue;
+    } else if (type == Type.LONG) {
+      return topValue;
+    } else {
+      throw new IllegalArgumentException(

Review comment:
       When it can't apply the optimization, this query just skips the 
optimization instead of throwing an exception (see `getDocIdSetIteratorOrNull`, 
where it returns a null iterator when the index sort doesn't match). I think we 
should also check the sort field type there and disable the optimization in 
that case.




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to