Skip to content

Commit

Permalink
iter
Browse files Browse the repository at this point in the history
  • Loading branch information
pmpailis committed Dec 4, 2024
1 parent 35274e7 commit 0e9b471
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,7 @@ public void onFailure(Exception e) {
});
});

return new RankDocsRetrieverBuilder(
rankWindowSize,
newRetrievers.stream().map(s -> s.retriever).toList(),
results::get,
newPreFilters
);
return new RankDocsRetrieverBuilder(rankWindowSize, newRetrievers.stream().map(s -> s.retriever).toList(), results::get);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,13 @@ public class RankDocsRetrieverBuilder extends RetrieverBuilder {
final List<RetrieverBuilder> sources;
final Supplier<RankDoc[]> rankDocs;

public RankDocsRetrieverBuilder(
int rankWindowSize,
List<RetrieverBuilder> sources,
Supplier<RankDoc[]> rankDocs,
List<QueryBuilder> preFilterQueryBuilders
) {
public RankDocsRetrieverBuilder(int rankWindowSize, List<RetrieverBuilder> sources, Supplier<RankDoc[]> rankDocs) {
this.rankWindowSize = rankWindowSize;
this.rankDocs = rankDocs;
if (sources == null || sources.isEmpty()) {
throw new IllegalArgumentException("sources must not be null or empty");
}
this.sources = sources;
this.preFilterQueryBuilders = preFilterQueryBuilders;
}

@Override
Expand Down Expand Up @@ -73,10 +67,6 @@ private boolean sourceShouldRewrite(QueryRewriteContext ctx) throws IOException
@Override
public RetrieverBuilder rewrite(QueryRewriteContext ctx) throws IOException {
assert false == sourceShouldRewrite(ctx) : "retriever sources should be rewritten first";
var rewrittenFilters = rewritePreFilters(ctx);
if (rewrittenFilters != preFilterQueryBuilders) {
return new RankDocsRetrieverBuilder(rankWindowSize, sources, rankDocs, rewrittenFilters);
}
return this;
}

Expand All @@ -94,7 +84,7 @@ public QueryBuilder topDocsQuery() {
boolQuery.should(query);
}
}
// ignore prefilters of this level, they are already propagated to children
// ignore prefilters of this level, they were already propagated to children
return boolQuery;
}

Expand Down Expand Up @@ -133,7 +123,7 @@ public void extractToSearchSourceBuilder(SearchSourceBuilder searchSourceBuilder
} else {
rankQuery = new RankDocsQueryBuilder(rankDocResults, null, false);
}
// ignore prefilters of this level, they are already propagated to children
// ignore prefilters of this level, they were already propagated to children
searchSourceBuilder.query(rankQuery);
if (sourceHasMinScore()) {
searchSourceBuilder.minScore(this.minScore() == null ? Float.MIN_VALUE : this.minScore());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,7 @@ private List<QueryBuilder> preFilters(QueryRewriteContext queryRewriteContext) t
}

private RankDocsRetrieverBuilder createRandomRankDocsRetrieverBuilder(QueryRewriteContext queryRewriteContext) throws IOException {
return new RankDocsRetrieverBuilder(
randomIntBetween(1, 100),
innerRetrievers(queryRewriteContext),
rankDocsSupplier(),
preFilters(queryRewriteContext)
);
return new RankDocsRetrieverBuilder(randomIntBetween(1, 100), innerRetrievers(queryRewriteContext), rankDocsSupplier());
}

public void testExtractToSearchSourceBuilder() throws IOException {
Expand Down

0 comments on commit 0e9b471

Please sign in to comment.