Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
afoucret committed May 27, 2024
1 parent 85c0d04 commit 1481e97
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -491,15 +491,15 @@ public ActionRequestValidationException validate() {
}

public ActionRequestValidationException validateRescores(ActionRequestValidationException validationException) {
RescorerBuilder<?> nonCombinableRescorer = null;
RescorerBuilder<?> nonCombinableRescorer = null;

if (source.rescores() == null) {
return validationException;
}

int paginationWindowSize = source.from() + source.size();

for (RescorerBuilder<?> currentRescorer: source.rescores()) {
for (RescorerBuilder<?> currentRescorer : source.rescores()) {
if (nonCombinableRescorer != null && nonCombinableRescorer.windowSize() < currentRescorer.windowSize()) {
validationException = addValidationError(
"unable to add a rescorer with [window_size: "
Expand All @@ -520,7 +520,7 @@ public ActionRequestValidationException validateRescores(ActionRequestValidation
+ paginationWindowSize
+ "] but was ["
+ currentRescorer.windowSize()
+"]",
+ "]",
validationException
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,8 @@ public void testForceSyntheticUnsupported() {

public void testRescoreChainValidation() {
{
SearchSourceBuilder source = new SearchSourceBuilder().from(10).size(10)
SearchSourceBuilder source = new SearchSourceBuilder().from(10)
.size(10)
.addRescorer(createRescorerMock(true, randomIntBetween(2, 10000)))
.addRescorer(createRescorerMock(true, randomIntBetween(2, 10000)))
.addRescorer(createRescorerMock(false, 50))
Expand All @@ -689,13 +690,16 @@ public void testRescoreChainValidation() {
assertThat(
validationErrors.validationErrors().get(0),
equalTo(
"rescorer [window_size] is too small and should be at least the value of [from + size: 20] but was [" + rescorer.windowSize() + "]"
"rescorer [window_size] is too small and should be at least the value of [from + size: 20] but was ["
+ rescorer.windowSize()
+ "]"
)
);
}

{
SearchSourceBuilder source = new SearchSourceBuilder().from(10).size(10)
SearchSourceBuilder source = new SearchSourceBuilder().from(10)
.size(10)
.addRescorer(createRescorerMock(true, randomIntBetween(2, 10000)))
.addRescorer(createRescorerMock(true, randomIntBetween(2, 10000)))
.addRescorer(createRescorerMock(false, 50))
Expand All @@ -706,7 +710,7 @@ public void testRescoreChainValidation() {
assertThat(
validationErrors.validationErrors().get(0),
equalTo(
"unable to add a rescorer with [window_size: 60] because a rescorer of type [not_combinable] with a smaller [window_size: 50] has been added before"
"unable to add a rescorer with [window_size: 60] because a rescorer of type [not_combinable] with a smaller [window_size: 50] has been added before"
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,14 @@ private RescorerBuilder<LearningToRankRescorerBuilder> doSearchRewrite(QueryRewr
@Override
protected LearningToRankRescorerContext innerBuildContext(int windowSize, SearchExecutionContext context) {
rescoreOccurred = true;
return new LearningToRankRescorerContext(windowSize, LearningToRankRescorer.INSTANCE, canCombineScores(), learningToRankConfig, localModel, context);
return new LearningToRankRescorerContext(
windowSize,
LearningToRankRescorer.INSTANCE,
canCombineScores(),
learningToRankConfig,
localModel,
context
);
}

@Override
Expand Down

0 comments on commit 1481e97

Please sign in to comment.