Skip to content

[8.17] Fix LTR rescorer with model alias (#126273) #126658

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/changelog/126273.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 126273
summary: Fix LTR rescorer with model alias
area: Ranking
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,7 @@ public ModelLoadingService(
this.licenseState = licenseState;
}

// for testing
String getModelId(String modelIdOrAlias) {
public String getModelId(String modelIdOrAlias) {
return modelAliasToId.getOrDefault(modelIdOrAlias, modelIdOrAlias);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public void loadLocalModel(String modelId, ActionListener<LocalModel> listener)
*/
public void loadLearningToRankConfig(String modelId, Map<String, Object> params, ActionListener<LearningToRankConfig> listener) {
trainedModelProvider.getTrainedModel(
modelId,
modelLoadingService.getModelId(modelId),
GetTrainedModelsAction.Includes.all(),
null,
ActionListener.wrap(trainedModelConfig -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,14 @@
import static org.hamcrest.Matchers.hasKey;
import static org.hamcrest.Matchers.hasSize;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

public class LearningToRankServiceTests extends ESTestCase {
public static final String GOOD_MODEL = "inference-entity-id";
Expand Down Expand Up @@ -185,7 +187,10 @@ protected NamedXContentRegistry xContentRegistry() {
}

private ModelLoadingService mockModelLoadingService() {
return mock(ModelLoadingService.class);
ModelLoadingService modelLoadingService = mock(ModelLoadingService.class);
when(modelLoadingService.getModelId(anyString())).thenAnswer(i -> i.getArgument(0));

return modelLoadingService;
}

@SuppressWarnings("unchecked")
Expand Down

This file was deleted.