diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/trainedmodel/ltr/QueryExtractorBuilder.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/trainedmodel/ltr/QueryExtractorBuilder.java index e6d20c845c222..4bbe92c6cc769 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/trainedmodel/ltr/QueryExtractorBuilder.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/trainedmodel/ltr/QueryExtractorBuilder.java @@ -70,6 +70,9 @@ public QueryExtractorBuilder(String featureName, QueryProvider query) { public QueryExtractorBuilder(String featureName, QueryProvider query, float defaultScore) { this.featureName = requireNonNull(featureName, FEATURE_NAME); this.query = requireNonNull(query, QUERY); + if (defaultScore < 0f) { + throw new IllegalArgumentException("[" + NAME + "] requires defaultScore to be positive."); + } this.defaultScore = defaultScore; }