From a5217451759f91bce7b325bb1f06312b56585116 Mon Sep 17 00:00:00 2001 From: Aurelien FOUCRET Date: Fri, 24 Nov 2023 11:22:49 +0100 Subject: [PATCH] Add some comments. --- .../ml/inference/ltr/LearnToRankService.java | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/ltr/LearnToRankService.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/ltr/LearnToRankService.java index e51aff3022e9c..1443ccd687620 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/ltr/LearnToRankService.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/ltr/LearnToRankService.java @@ -68,10 +68,24 @@ public LearnToRankService( this.parserConfiguration = parserConfiguration; } + /** + * Asynchronously load a regression model to be used for learn to rank. + * + * @param modelId The model id to be loaded. + * @param listener Response listener. + */ public void loadLocalModel(String modelId, ActionListener listener) { modelLoadingService.getModelForLearnToRank(modelId, listener); } + /** + * Asynchronously load the learn to rank config by model id. + * Once the model is loaded, templates are executed using params provided. + * + * @param modelId Id of the model. + * @param params Templates params. + * @param listener Response listener. + */ public void loadLearnToRankConfig(String modelId, Map params, ActionListener listener) { trainedModelProvider.getTrainedModel( modelId, @@ -98,6 +112,15 @@ public void loadLearnToRankConfig(String modelId, Map params, Ac ); } + /** + * Applies templates params to a {@link LearnToRankConfig} object. + * + * @param config Original config. + * @param params Templates params. + * @return A {@link LearnToRankConfig} object with templates applied. + * + * @throws IOException + */ private LearnToRankConfig applyParams(LearnToRankConfig config, Map params) throws IOException { if (scriptService.isLangSupported(DEFAULT_TEMPLATE_LANG) == false) { return config; @@ -117,6 +140,15 @@ private LearnToRankConfig applyParams(LearnToRankConfig config, Map params @@ -128,6 +160,15 @@ private LearnToRankFeatureExtractorBuilder applyParams( return featureExtractorBuilder; } + /** + * Applies templates to a {@link QueryExtractorBuilder} object. + * + * @param queryExtractorBuilder Source query extractor builder. + * @param params Templates params. + * @return A {@link QueryExtractorBuilder} with templates applied. + * + * @throws IOException + */ private QueryExtractorBuilder applyParams(QueryExtractorBuilder queryExtractorBuilder, Map params) throws IOException { String templateSource = templateSource(queryExtractorBuilder.query());