Skip to content

Commit

Permalink
Add WithFieldName implementation to KNNQueryBuilder (#2398)
Browse files Browse the repository at this point in the history
* Add WithFieldName implementation to KNNQueryBuilder

Signed-off-by: Mark Wu <[email protected]>

* Update CHANGELOG.md

Signed-off-by: Mark Wu <[email protected]>

---------

Signed-off-by: Mark Wu <[email protected]>
  • Loading branch information
markwu-sde authored Jan 16, 2025
1 parent 5c63fde commit 7e817f2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Optimizes lucene query execution to prevent unnecessary rewrites (#2305)[https://github.com/opensearch-project/k-NN/pull/2305]
- Add check to directly use ANN Search when filters match all docs. (#2320)[https://github.com/opensearch-project/k-NN/pull/2320]
- Use one formula to calculate cosine similarity (#2357)[https://github.com/opensearch-project/k-NN/pull/2357]
- Add WithFieldName implementation to KNNQueryBuilder (#2398)[https://github.com/opensearch-project/k-NN/pull/2398]
### Bug Fixes
* Fixing the bug when a segment has no vector field present for disk based vector search (#2282)[https://github.com/opensearch-project/k-NN/pull/2282]
* Fixing the bug where search fails with "fields" parameter for an index with a knn_vector field (#2314)[https://github.com/opensearch-project/k-NN/pull/2314]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.opensearch.index.query.QueryBuilder;
import org.opensearch.index.query.QueryRewriteContext;
import org.opensearch.index.query.QueryShardContext;
import org.opensearch.index.query.WithFieldName;
import org.opensearch.knn.index.engine.KNNMethodConfigContext;
import org.opensearch.knn.index.engine.model.QueryContext;
import org.opensearch.knn.index.engine.qframe.QuantizationConfig;
Expand Down Expand Up @@ -68,7 +69,7 @@
// The builder validates the member variables so access to the constructor is prohibited to not accidentally bypass validations
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@Log4j2
public class KNNQueryBuilder extends AbstractQueryBuilder<KNNQueryBuilder> {
public class KNNQueryBuilder extends AbstractQueryBuilder<KNNQueryBuilder> implements WithFieldName {
private static ModelDao modelDao;

public static final ParseField VECTOR_FIELD = new ParseField("vector");
Expand Down Expand Up @@ -364,6 +365,7 @@ protected void doWriteTo(StreamOutput out) throws IOException {
/**
* @return The field name used in this query
*/
@Override
public String fieldName() {
return this.fieldName;
}
Expand Down

0 comments on commit 7e817f2

Please sign in to comment.