Skip to content

Commit

Permalink
Rename knnQueryFilter to filter
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Gaievski <[email protected]>
  • Loading branch information
martin-gaievski committed Aug 19, 2022
1 parent 5b0bb27 commit ecf8aee
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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<QueryBuilder> getKnnQueryFilter() {
return Optional.ofNullable(knnQueryFilter);
public Optional<QueryBuilder> getFilter() {
return Optional.ofNullable(filter);
}

public Optional<QueryShardContext> getContext() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit ecf8aee

Please sign in to comment.