QueryRescorer should keep the window size when rewriting (#36836)

This attribute being controlled by the parent class it's easy to miss
it during rewrites.
This commit is contained in:
David Causse 2018-12-19 21:42:18 +01:00 committed by Christoph Büscher
parent 5185d61ad1
commit 3412627efe
2 changed files with 5 additions and 0 deletions

View File

@ -250,6 +250,9 @@ public class QueryRescorerBuilder extends RescorerBuilder<QueryRescorerBuilder>
queryRescoreBuilder.setQueryWeight(queryWeight);
queryRescoreBuilder.setRescoreQueryWeight(rescoreQueryWeight);
queryRescoreBuilder.setScoreMode(scoreMode);
if (windowSize() != null) {
queryRescoreBuilder.windowSize(windowSize());
}
return queryRescoreBuilder;
}
}

View File

@ -200,11 +200,13 @@ public class QueryRescorerBuilderTests extends ESTestCase {
rescoreBuilder.setQueryWeight(randomFloat());
rescoreBuilder.setRescoreQueryWeight(randomFloat());
rescoreBuilder.setScoreMode(QueryRescoreMode.Max);
rescoreBuilder.windowSize(randomIntBetween(0, 100));
QueryRescorerBuilder rescoreRewritten = rescoreBuilder.rewrite(mockShardContext);
assertEquals(rescoreRewritten.getQueryWeight(), rescoreBuilder.getQueryWeight(), 0.01f);
assertEquals(rescoreRewritten.getRescoreQueryWeight(), rescoreBuilder.getRescoreQueryWeight(), 0.01f);
assertEquals(rescoreRewritten.getScoreMode(), rescoreBuilder.getScoreMode());
assertEquals(rescoreRewritten.windowSize(), rescoreBuilder.windowSize());
}
/**