dungba88 commented on code in PR #14009:
URL: https://github.com/apache/lucene/pull/14009#discussion_r2144373185


##########
lucene/core/src/java/org/apache/lucene/search/RescoreTopNQuery.java:
##########
@@ -0,0 +1,128 @@
+/*
+ * 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.search;
+
+import java.io.IOException;
+import java.util.Objects;
+import org.apache.lucene.index.IndexReader;
+
+/**
+ * A Query that re-scores another Query with a DoubleValueSource function and 
cut-off the results at
+ * top N.
+ *
+ * @lucene.experimental
+ */
+public class RescoreTopNQuery extends Query {
+
+  private final int n;
+  private final Query query;
+  private final DoubleValuesSource valuesSource;
+
+  /**
+   * Execute the inner Query, re-score using a customizable DoubleValueSource 
and trim down the

Review Comment:
   That's one of them, it does not depend on the score mode 
(`FunctionScoreQuery` will be a no-op if `needsScores = false`) and it also 
trim down the results to N. 
   
   So it's more similar to `Rescorer` class, except that it can rescore a 
sub-Query instead of top-level Query in the final `IndexSearcher.search()`.
   
   The nuance is important in cases where we don't need the overall score 
(using ConstantScoreQuery) but still want to rescore and trim down results in 
some sub-Query (like KnnFloatVectorQuery).
   
   It's heavily influenced by KnnFloatVectorQuery but API-wise there would be 
no such limitation.



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