kaivalnp commented on code in PR #16654:
URL: https://github.com/apache/lucene/pull/16654#discussion_r3983843205


##########
lucene/core/src/java/org/apache/lucene/search/ByteVectorSimilarityQuery.java:
##########
@@ -35,113 +35,158 @@
 public class ByteVectorSimilarityQuery extends AbstractVectorSimilarityQuery {
   private final byte[] target;
 
-  /**
-   * Search for all (approximate) byte vectors above a similarity threshold 
using {@link
-   * VectorSimilarityCollector}, with a caller-supplied {@link 
KnnSearchStrategy}. If a filter is
-   * applied, it traverses as many nodes as the cost of the filter, and then 
falls back to exact
-   * search if results are incomplete.
-   *
-   * @param field a field that has been indexed as a {@link 
KnnByteVectorField}.
-   * @param target the target of the search.
-   * @param resultSimilarity similarity score for result collection.
-   * @param decay decay factor for graph traversal buffer.
-   * @param filter a filter applied before the vector search.
-   * @param searchStrategy the {@link KnnSearchStrategy} to use during graph 
search. If {@code
-   *     null}, this query's own default is used: an {@link Hnsw} with {@code
-   *     filteredSearchThreshold == 0}, which preserves this query's filter 
handling. Note this
-   *     differs from {@link Hnsw#DEFAULT}, which uses a threshold of 60. The 
underlying format may
-   *     not support all strategies and is free to ignore the requested 
strategy.
-   */
-  public static ByteVectorSimilarityQuery createNew(
-      String field,
-      byte[] target,
-      float resultSimilarity,
-      float decay,
-      Query filter,
-      KnnSearchStrategy searchStrategy) {
-    return new ByteVectorSimilarityQuery(
-        field, target, resultSimilarity, decay, filter, searchStrategy);
-  }
+  /** A {@link ByteVectorSimilarityQuery} with an adaptive threshold for graph 
traversal. */
+  public static class Adaptive extends ByteVectorSimilarityQuery {
+    /**
+     * Search for all (approximate) byte vectors above a similarity threshold 
using {@link
+     * VectorSimilarityCollector}, with a caller-supplied {@link 
KnnSearchStrategy}. If a filter is
+     * applied, it traverses as many nodes as the cost of the filter, and then 
falls back to exact
+     * search if results are incomplete.
+     *
+     * @param field a field that has been indexed as a {@link 
KnnByteVectorField}.
+     * @param target the target of the search.
+     * @param resultSimilarity similarity score for result collection.
+     * @param decay decay factor for graph traversal buffer.
+     * @param filter a filter applied before the vector search.
+     * @param searchStrategy the {@link KnnSearchStrategy} to use during graph 
search. If {@code
+     *     null}, this query's own default is used: an {@link Hnsw} with {@code
+     *     filteredSearchThreshold == 0}, which preserves this query's filter 
handling. Note this
+     *     differs from {@link Hnsw#DEFAULT}, which uses a threshold of 60. 
The underlying format
+     *     may not support all strategies and is free to ignore the requested 
strategy.
+     */
+    public Adaptive(
+        String field,
+        byte[] target,
+        float resultSimilarity,
+        float decay,
+        Query filter,
+        KnnSearchStrategy searchStrategy) {
+      super(field, target, resultSimilarity, decay, filter, searchStrategy);
+    }
 
-  /**
-   * Search for all (approximate) byte vectors above a similarity threshold 
using {@link
-   * VectorSimilarityCollector}, with the default {@link KnnSearchStrategy}. 
If a filter is applied,
-   * it traverses as many nodes as the cost of the filter, and then falls back 
to exact search if
-   * results are incomplete.
-   *
-   * @param field a field that has been indexed as a {@link 
KnnByteVectorField}.
-   * @param target the target of the search.
-   * @param decay decay factor for graph traversal buffer.
-   * @param resultSimilarity similarity score for result collection.
-   * @param filter a filter applied before the vector search.
-   */
-  public static ByteVectorSimilarityQuery createNew(
-      String field, byte[] target, float resultSimilarity, float decay, Query 
filter) {
-    return createNew(field, target, resultSimilarity, decay, filter, 
DEFAULT_STRATEGY);
-  }
+    /**
+     * Search for all (approximate) byte vectors above a similarity threshold 
using {@link
+     * VectorSimilarityCollector}, with the default {@link KnnSearchStrategy}. 
If a filter is
+     * applied, it traverses as many nodes as the cost of the filter, and then 
falls back to exact
+     * search if results are incomplete.
+     *
+     * @param field a field that has been indexed as a {@link 
KnnByteVectorField}.
+     * @param target the target of the search.
+     * @param resultSimilarity similarity score for result collection.
+     * @param decay decay factor for graph traversal buffer.
+     * @param filter a filter applied before the vector search.
+     */
+    public Adaptive(
+        String field, byte[] target, float resultSimilarity, float decay, 
Query filter) {
+      this(field, target, resultSimilarity, decay, filter, DEFAULT_STRATEGY);
+    }
 
-  /**
-   * Search for all (approximate) byte vectors above a similarity threshold 
using {@link
-   * VectorSimilarityCollector}. If a filter is applied, it traverses as many 
nodes as the cost of
-   * the filter, and then falls back to exact search if results are incomplete.
-   *
-   * @param field a field that has been indexed as a {@link 
KnnByteVectorField}.
-   * @param target the target of the search.
-   * @param resultSimilarity similarity score for result collection.
-   * @param filter a filter applied before the vector search.
-   */
-  public static ByteVectorSimilarityQuery createNew(
-      String field, byte[] target, float resultSimilarity, Query filter) {
-    return createNew(field, target, resultSimilarity, DEFAULT_DECAY, filter);
-  }
+    /**
+     * Search for all (approximate) byte vectors above a similarity threshold 
using {@link
+     * VectorSimilarityCollector}. If a filter is applied, it traverses as 
many nodes as the cost of
+     * the filter, and then falls back to exact search if results are 
incomplete.
+     *
+     * @param field a field that has been indexed as a {@link 
KnnByteVectorField}.
+     * @param target the target of the search.
+     * @param resultSimilarity similarity score for result collection.
+     * @param filter a filter applied before the vector search.
+     */
+    public Adaptive(String field, byte[] target, float resultSimilarity, Query 
filter) {
+      this(field, target, resultSimilarity, DEFAULT_DECAY, filter);
+    }
 
-  /**
-   * Search for all (approximate) byte vectors above a similarity threshold 
using {@link
-   * VectorSimilarityCollector}.
-   *
-   * @param field a field that has been indexed as a {@link 
KnnByteVectorField}.
-   * @param target the target of the search.
-   * @param resultSimilarity similarity score for result collection.
-   */
-  public static ByteVectorSimilarityQuery createNew(
-      String field, byte[] target, float resultSimilarity) {
-    return createNew(field, target, resultSimilarity, null);
+    /**
+     * Search for all (approximate) byte vectors above a similarity threshold 
using {@link
+     * VectorSimilarityCollector}.
+     *
+     * @param field a field that has been indexed as a {@link 
KnnByteVectorField}.
+     * @param target the target of the search.
+     * @param resultSimilarity similarity score for result collection.
+     */
+    public Adaptive(String field, byte[] target, float resultSimilarity) {
+      this(field, target, resultSimilarity, null);
+    }
   }
 
   /**
-   * Search for all (approximate) byte vectors above a similarity threshold 
using {@link
-   * VectorSimilarityCollector}, with the default {@link KnnSearchStrategy}. 
If a filter is applied,
-   * it traverses as many nodes as the cost of the filter, and then falls back 
to exact search if
-   * results are incomplete.
+   * A {@link ByteVectorSimilarityQuery} with an explicit threshold for graph 
traversal.

Review Comment:
   Added a note, please let me know if it should be enhanced.



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