This is an automated email from the ASF dual-hosted git repository.

ishan pushed a commit to branch jira/solr-17927
in repository https://gitbox.apache.org/repos/asf/solr.git

commit 1bccb06fbc29c261ff525b7fc8b5e09fd9baf501
Author: punAhuja <[email protected]>
AuthorDate: Thu Oct 30 16:54:22 2025 +0530

    Added some comments and validation for efSearch >= topK
---
 .../java/org/apache/solr/search/vector/KnnQParser.java   |  8 +++++++-
 .../solr/search/vector/SolrKnnByteVectorQuery.java       | 16 ++++++++++++++++
 .../solr/search/vector/SolrKnnFloatVectorQuery.java      | 16 ++++++++++++++++
 3 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/solr/core/src/java/org/apache/solr/search/vector/KnnQParser.java 
b/solr/core/src/java/org/apache/solr/search/vector/KnnQParser.java
index 95afb3ef18f..9f8d9f6de79 100644
--- a/solr/core/src/java/org/apache/solr/search/vector/KnnQParser.java
+++ b/solr/core/src/java/org/apache/solr/search/vector/KnnQParser.java
@@ -108,7 +108,13 @@ public class KnnQParser extends AbstractVectorQParserBase {
     final DenseVectorField denseVectorType = getCheckedFieldType(schemaField);
     final String vectorToSearch = getVectorToSearch();
     final int topK = localParams.getInt(TOP_K, DEFAULT_TOP_K);
-    final int efSearch = localParams.getInt("ef-search", topK * 2);
+    final int efSearch = localParams.getInt("efSearch", topK * 2);
+    if (efSearch < topK) {
+      throw new IllegalArgumentException(
+          "efSearch (" + efSearch + ") must be >= topK (" + topK + ")");
+    }
+
+    final Integer filteredSearchThreshold = 
localParams.getInt(FILTERED_SEARCH_THRESHOLD);
 
     return denseVectorType.getKnnVectorQuery(
         schemaField.getName(),
diff --git 
a/solr/core/src/java/org/apache/solr/search/vector/SolrKnnByteVectorQuery.java 
b/solr/core/src/java/org/apache/solr/search/vector/SolrKnnByteVectorQuery.java
index e16866bacd5..6fd721cb414 100644
--- 
a/solr/core/src/java/org/apache/solr/search/vector/SolrKnnByteVectorQuery.java
+++ 
b/solr/core/src/java/org/apache/solr/search/vector/SolrKnnByteVectorQuery.java
@@ -24,6 +24,8 @@ public class SolrKnnByteVectorQuery extends 
KnnByteVectorQuery {
   private final int topK;
 
   public SolrKnnByteVectorQuery(String field, byte[] target, int topK, int 
efSearch, Query filter) {
+    // efSearch is used as 'k' to explore this many vectors in HNSW, then topK 
results are returned
+    // to the user
     super(field, target, efSearch, filter);
     this.topK = topK;
   }
@@ -32,4 +34,18 @@ public class SolrKnnByteVectorQuery extends 
KnnByteVectorQuery {
   protected TopDocs mergeLeafResults(TopDocs[] perLeafResults) {
     return TopDocs.merge(topK, perLeafResults);
   }
+
+  @Override
+  public boolean equals(Object obj) {
+    if (this == obj) return true;
+    if (!super.equals(obj)) return false;
+    if (getClass() != obj.getClass()) return false;
+    SolrKnnByteVectorQuery other = (SolrKnnByteVectorQuery) obj;
+    return this.topK == other.topK;
+  }
+
+  @Override
+  public int hashCode() {
+    return 31 * super.hashCode() + Integer.hashCode(topK);
+  }
 }
diff --git 
a/solr/core/src/java/org/apache/solr/search/vector/SolrKnnFloatVectorQuery.java 
b/solr/core/src/java/org/apache/solr/search/vector/SolrKnnFloatVectorQuery.java
index 60eb4f19a57..68089d66014 100644
--- 
a/solr/core/src/java/org/apache/solr/search/vector/SolrKnnFloatVectorQuery.java
+++ 
b/solr/core/src/java/org/apache/solr/search/vector/SolrKnnFloatVectorQuery.java
@@ -25,6 +25,8 @@ public class SolrKnnFloatVectorQuery extends 
KnnFloatVectorQuery {
 
   public SolrKnnFloatVectorQuery(
       String field, float[] target, int topK, int efSearch, Query filter) {
+    // efSearch is used as 'k' to explore this many vectors in HNSW then topK 
results are returned
+    // to the user
     super(field, target, efSearch, filter);
     this.topK = topK;
   }
@@ -33,4 +35,18 @@ public class SolrKnnFloatVectorQuery extends 
KnnFloatVectorQuery {
   protected TopDocs mergeLeafResults(TopDocs[] perLeafResults) {
     return TopDocs.merge(topK, perLeafResults);
   }
+
+  @Override
+  public boolean equals(Object obj) {
+    if (this == obj) return true;
+    if (!super.equals(obj)) return false;
+    if (getClass() != obj.getClass()) return false;
+    SolrKnnFloatVectorQuery other = (SolrKnnFloatVectorQuery) obj;
+    return this.topK == other.topK;
+  }
+
+  @Override
+  public int hashCode() {
+    return 31 * super.hashCode() + Integer.hashCode(topK);
+  }
 }

Reply via email to