Skip to content

Commit

Permalink
Rename LearnToRankInferenceRescorerContext into LearnToRankRescorerCo…
Browse files Browse the repository at this point in the history
…ntext
  • Loading branch information
afoucret committed Nov 23, 2023
1 parent 2113447 commit 239e73a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public TopDocs rescore(TopDocs topDocs, IndexSearcher searcher, RescoreContext r
if (topDocs.scoreDocs.length == 0) {
return topDocs;
}
LearnToRankInferenceRescorerContext ltrRescoreContext = (LearnToRankInferenceRescorerContext) rescoreContext;
LearnToRankRescorerContext ltrRescoreContext = (LearnToRankRescorerContext) rescoreContext;
if (ltrRescoreContext.regressionModelDefinition == null) {
throw new IllegalStateException("local model reference is null, missing rewriteAndFetch before rescore phase?");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,9 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
}

@Override
protected LearnToRankInferenceRescorerContext innerBuildContext(int windowSize, SearchExecutionContext context) {
protected LearnToRankRescorerContext innerBuildContext(int windowSize, SearchExecutionContext context) {
rescoreOccurred = true;
return new LearnToRankInferenceRescorerContext(
return new LearnToRankRescorerContext(
windowSize,
LearnToRankRescorer.INSTANCE,
inferenceConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import java.util.ArrayList;
import java.util.List;

public class LearnToRankInferenceRescorerContext extends RescoreContext {
public class LearnToRankRescorerContext extends RescoreContext {

final SearchExecutionContext executionContext;
final LocalModel regressionModelDefinition;
Expand All @@ -37,7 +37,7 @@ public class LearnToRankInferenceRescorerContext extends RescoreContext {
* @param regressionModelDefinition The local model inference definition, may be null during certain search phases.
* @param executionContext The local shard search context
*/
public LearnToRankInferenceRescorerContext(
public LearnToRankRescorerContext(
int windowSize,
Rescorer rescorer,
LearnToRankConfig learnToRankConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,17 @@ public void testMustRewrite() {
() -> testModelLoader
);
SearchExecutionContext context = createSearchExecutionContext();
LearnToRankInferenceRescorerContext learnToRankInferenceRescorerContext = learnToRankRescorerBuilder.innerBuildContext(
LearnToRankRescorerContext learnToRankRescorerContext = learnToRankRescorerBuilder.innerBuildContext(
randomIntBetween(1, 30),
context
);
IllegalStateException e = expectThrows(
IllegalStateException.class,
() -> learnToRankInferenceRescorerContext.rescorer()
() -> learnToRankRescorerContext.rescorer()
.rescore(
new TopDocs(new TotalHits(10, TotalHits.Relation.EQUAL_TO), new ScoreDoc[10]),
mock(IndexSearcher.class),
learnToRankInferenceRescorerContext
learnToRankRescorerContext
)
);
assertEquals("local model reference is null, missing rewriteAndFetch before rescore phase?", e.getMessage());
Expand Down Expand Up @@ -274,7 +274,7 @@ public void testBuildContext() throws Exception {
(LearnToRankConfig) GOOD_MODEL_CONFIG.getInferenceConfig(),
localModel
);
LearnToRankInferenceRescorerContext rescoreContext = learnToRankRescorerBuilder.innerBuildContext(20, context);
LearnToRankRescorerContext rescoreContext = learnToRankRescorerBuilder.innerBuildContext(20, context);
assertNotNull(rescoreContext);
assertThat(rescoreContext.getWindowSize(), equalTo(20));
List<FeatureExtractor> featureExtractors = rescoreContext.buildFeatureExtractors(context.searcher());
Expand Down

0 comments on commit 239e73a

Please sign in to comment.