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 11f978151..59b508d8f 100644 --- a/src/main/java/org/opensearch/knn/index/query/KNNQueryBuilder.java +++ b/src/main/java/org/opensearch/knn/index/query/KNNQueryBuilder.java @@ -249,7 +249,7 @@ protected Query doToQuery(QueryShardContext context) { .fieldName(this.fieldName) .vector(this.vector) .k(this.k) - .knnQueryFilter(this.filter) + .filter(this.filter) .context(context) .build(); return KNNQueryFactory.create(createQueryRequest); diff --git a/src/main/java/org/opensearch/knn/index/query/KNNQueryFactory.java b/src/main/java/org/opensearch/knn/index/query/KNNQueryFactory.java index eb5236d26..10c8edd1a 100644 --- a/src/main/java/org/opensearch/knn/index/query/KNNQueryFactory.java +++ b/src/main/java/org/opensearch/knn/index/query/KNNQueryFactory.java @@ -80,11 +80,11 @@ public static Query create(CreateQueryRequest createQueryRequest) { createQueryRequest.getK() ) ); - if (createQueryRequest.getKnnQueryFilter().isPresent()) { + if (createQueryRequest.getFilter().isPresent()) { final QueryShardContext queryShardContext = createQueryRequest.getContext() .orElseThrow(() -> new RuntimeException("Shard context cannot be null")); try { - final Query filterQuery = createQueryRequest.getKnnQueryFilter().get().toQuery(queryShardContext); + final Query filterQuery = createQueryRequest.getFilter().get().toQuery(queryShardContext); return new KnnVectorQuery( createQueryRequest.getFieldName(), createQueryRequest.getVector(), @@ -118,12 +118,12 @@ static class CreateQueryRequest { @Getter private int k; // can be null in cases filter not passed with the knn query - private QueryBuilder knnQueryFilter; + private QueryBuilder filter; // can be null in cases filter not passed with the knn query private QueryShardContext context; - public Optional getKnnQueryFilter() { - return Optional.ofNullable(knnQueryFilter); + public Optional getFilter() { + return Optional.ofNullable(filter); } public Optional getContext() { diff --git a/src/test/java/org/opensearch/knn/index/query/KNNQueryFactoryTests.java b/src/test/java/org/opensearch/knn/index/query/KNNQueryFactoryTests.java index 6d041687d..908ea1021 100644 --- a/src/test/java/org/opensearch/knn/index/query/KNNQueryFactoryTests.java +++ b/src/test/java/org/opensearch/knn/index/query/KNNQueryFactoryTests.java @@ -67,7 +67,7 @@ public void testCreateLuceneQueryWithFilter() { .vector(testQueryVector) .k(testK) .context(mockQueryShardContext) - .knnQueryFilter(filter) + .filter(filter) .build(); Query query = KNNQueryFactory.create(createQueryRequest); assertTrue(query instanceof KnnVectorQuery);