alessandrobenedetti commented on code in PR #4919:
URL: https://github.com/apache/solr/pull/4919#discussion_r4482732865


##########
solr/core/src/java/org/apache/solr/search/vector/SolrRescoreTopNQuery.java:
##########
@@ -0,0 +1,64 @@
+/*
+ * 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.solr.search.vector;
+
+import java.io.IOException;
+import org.apache.lucene.search.DoubleValuesSource;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.MatchNoDocsQuery;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.RescoreTopNQuery;
+
+/**
+ * A {@link RescoreTopNQuery} that tolerates an inner query matching no 
documents.
+ *
+ * <p>{@link RescoreTopNQuery#rewrite} unconditionally hands its collected 
hits to {@code
+ * DocAndScoreQuery#createDocAndScoreQuery}, which requires at least one hit: 
it asserts as much,
+ * and without assertions enabled it reads element zero of an empty array. 
{@code
+ * AbstractKnnVectorQuery#rewrite} guards the very same call by returning 
{@link MatchNoDocsQuery},
+ * but the re-ranking query has no equivalent guard, so an oversampled knn 
query that matches
+ * nothing (a restrictive {@code preFilter}, say) fails instead of returning 
no results.
+ *
+ * <p>TODO: remove this class once the guard is added upstream in Lucene and 
Solr picks up a release

Review Comment:
   I suggest we open a Lucene GitHub issue about that (and when comfortable, a 
pull request).
   In here we can add specifically a link to the github issue and mention 'to 
be removed as soon as this issue is in the Lucene version we adopt)



-- 
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