diff --git a/CHANGELOG.md b/CHANGELOG.md index 0cdca353a..1722e7e2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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] diff --git a/src/main/java/org/opensearch/knn/index/query/KNNQueryBuilder.java b/src/main/java/org/opensearch/knn/index/query/KNNQueryBuilder.java index ee18394f6..6015d8482 100644 --- a/src/main/java/org/opensearch/knn/index/query/KNNQueryBuilder.java +++ b/src/main/java/org/opensearch/knn/index/query/KNNQueryBuilder.java @@ -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; @@ -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 { +public class KNNQueryBuilder extends AbstractQueryBuilder implements WithFieldName { private static ModelDao modelDao; public static final ParseField VECTOR_FIELD = new ParseField("vector"); @@ -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; }