Skip to content

Commit

Permalink
Spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
mayya-sharipova committed Oct 2, 2024
1 parent 6e6abae commit 426db4d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,13 @@ public class KnnScoreDocQueryBuilder extends AbstractQueryBuilder<KnnScoreDocQue
* @param scoreDocs the docs and scores this query should match. The array must be
* sorted in order of ascending doc IDs.
*/
public KnnScoreDocQueryBuilder(ScoreDoc[] scoreDocs, String fieldName,
VectorData queryVector, Float vectorSimilarity, List<QueryBuilder> filterQueries) {
public KnnScoreDocQueryBuilder(
ScoreDoc[] scoreDocs,
String fieldName,
VectorData queryVector,
Float vectorSimilarity,
List<QueryBuilder> filterQueries
) {
this.scoreDocs = scoreDocs;
this.fieldName = fieldName;
this.queryVector = queryVector;
Expand Down Expand Up @@ -83,7 +88,7 @@ public KnnScoreDocQueryBuilder(StreamInput in) throws IOException {
} else {
this.vectorSimilarity = null;
}
if (in.getTransportVersion().onOrAfter(TransportVersions.TO_CHILD_BLOCK_JOIN_QUERY)){
if (in.getTransportVersion().onOrAfter(TransportVersions.TO_CHILD_BLOCK_JOIN_QUERY)) {
this.filterQueries = readQueries(in);
} else {
this.filterQueries = List.of();
Expand Down Expand Up @@ -111,8 +116,6 @@ Float vectorSimilarity() {
return vectorSimilarity;
}



@Override
protected void doWriteTo(StreamOutput out) throws IOException {
out.writeArray(Lucene::writeScoreDoc, scoreDocs);
Expand All @@ -133,7 +136,7 @@ protected void doWriteTo(StreamOutput out) throws IOException {
|| out.getTransportVersion().isPatchFrom(TransportVersions.FIX_VECTOR_SIMILARITY_INNER_HITS_BACKPORT_8_15)) {
out.writeOptionalFloat(vectorSimilarity);
}
if (out.getTransportVersion().onOrAfter(TransportVersions.TO_CHILD_BLOCK_JOIN_QUERY)){
if (out.getTransportVersion().onOrAfter(TransportVersions.TO_CHILD_BLOCK_JOIN_QUERY)) {
writeQueries(out, filterQueries);
}
}
Expand Down Expand Up @@ -199,9 +202,9 @@ protected QueryBuilder doRewrite(QueryRewriteContext queryRewriteContext) throws
// so add them as should clauses to a filter
BoolQueryBuilder boolQuery = new BoolQueryBuilder();
boolQuery.must(exactKnnQuery);
boolQuery.filter(new BoolQueryBuilder()
.should(filterQueryChildren)
.should(new ToChildBlockJoinQueryBuilder(filterQueryChildren)));
boolQuery.filter(
new BoolQueryBuilder().should(filterQueryChildren).should(new ToChildBlockJoinQueryBuilder(filterQueryChildren))
);
return boolQuery;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,9 +434,9 @@ protected QueryBuilder doRewrite(QueryRewriteContext ctx) throws IOException {
// so add them as should clauses to a filter
BoolQueryBuilder boolQuery = new BoolQueryBuilder();
boolQuery.must(exactKnnQuery);
boolQuery.filter(new BoolQueryBuilder()
.should(filterQueryChildren)
.should(new ToChildBlockJoinQueryBuilder(filterQueryChildren)));
boolQuery.filter(
new BoolQueryBuilder().should(filterQueryChildren).should(new ToChildBlockJoinQueryBuilder(filterQueryChildren))
);
return boolQuery;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@

import static org.hamcrest.CoreMatchers.instanceOf;

public class ToChildBlockJoinQueryBuilderTests extends AbstractQueryTestCase< ToChildBlockJoinQueryBuilder> {
public class ToChildBlockJoinQueryBuilderTests extends AbstractQueryTestCase<ToChildBlockJoinQueryBuilder> {
@Override
protected ToChildBlockJoinQueryBuilder doCreateTestQueryBuilder() {
String filterFieldName = randomBoolean() ? KEYWORD_FIELD_NAME : TEXT_FIELD_NAME;
return new ToChildBlockJoinQueryBuilder(QueryBuilders.termQuery(filterFieldName, randomAlphaOfLength(10)));
}

@Override
protected void doAssertLuceneQuery(ToChildBlockJoinQueryBuilder queryBuilder, Query query,
SearchExecutionContext context) throws IOException {
protected void doAssertLuceneQuery(ToChildBlockJoinQueryBuilder queryBuilder, Query query, SearchExecutionContext context)
throws IOException {
assertThat(query, instanceOf(ToChildBlockJoinQuery.class));
}

Expand Down

0 comments on commit 426db4d

Please sign in to comment.