diff --git a/server/src/main/java/org/elasticsearch/action/search/SearchRequest.java b/server/src/main/java/org/elasticsearch/action/search/SearchRequest.java index 1f8bbda081e4e..4e3fdbc9633b9 100644 --- a/server/src/main/java/org/elasticsearch/action/search/SearchRequest.java +++ b/server/src/main/java/org/elasticsearch/action/search/SearchRequest.java @@ -442,7 +442,8 @@ public ActionRequestValidationException validate() { } } if (source.rescores() != null) { - for (@SuppressWarnings("rawtypes") RescorerBuilder rescoreBuilder : source.rescores()) { + for (@SuppressWarnings("rawtypes") + RescorerBuilder rescoreBuilder : source.rescores()) { validationException = rescoreBuilder.validate(this, validationException); } } diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/ltr/LearningToRankRescorer.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/ltr/LearningToRankRescorer.java index 559f1c0d153b8..13629c36f1492 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/ltr/LearningToRankRescorer.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/ltr/LearningToRankRescorer.java @@ -62,7 +62,6 @@ public TopDocs rescore(TopDocs topDocs, IndexSearcher searcher, RescoreContext r // We will truncate the {@link TopDocs} to the window size so rescoring will be done on the full topDocs. topDocs = topN(topDocs, rescoreContext.getWindowSize()); - // Save doc IDs for which rescoring was applied to be used in score explanation Set topDocIDs = Arrays.stream(topDocs.scoreDocs).map(scoreDoc -> scoreDoc.doc).collect(toUnmodifiableSet()); rescoreContext.setRescoredDocs(topDocIDs); @@ -134,7 +133,6 @@ public Explanation explain(int topLevelDocId, IndexSearcher searcher, RescoreCon return null; } - /** Returns a new {@link TopDocs} with the topN from the incoming one, or the same TopDocs if the number of hits is already <= * topN. */ private static TopDocs topN(TopDocs in, int topN) { diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/ltr/LearningToRankRescorerBuilder.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/ltr/LearningToRankRescorerBuilder.java index 36e3b00b2f17a..76ed09dedef25 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/ltr/LearningToRankRescorerBuilder.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/ltr/LearningToRankRescorerBuilder.java @@ -158,14 +158,16 @@ public ActionRequestValidationException validate(SearchRequest searchRequest, Ac RescorerBuilder nextRescorer = rescorers.get(i); int nextRescorerWindowSize = nextRescorer.windowSize() != null ? nextRescorer.windowSize() : DEFAULT_WINDOW_SIZE; if (windowSize() < nextRescorerWindowSize) { - return addValidationError("unable to add a rescorer with [window_size: " - + nextRescorer.windowSize() - + "] because a rescorer of type [" - + nextRescorer.getWriteableName() - + "] with a smaller [window_size: " - + windowSize() - + "] has been added before", - validationException); + return addValidationError( + "unable to add a rescorer with [window_size: " + + nextRescorer.windowSize() + + "] because a rescorer of type [" + + nextRescorer.getWriteableName() + + "] with a smaller [window_size: " + + windowSize() + + "] has been added before", + validationException + ); } } diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/inference/ltr/LearningToRankRescorerBuilderSerializationTests.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/inference/ltr/LearningToRankRescorerBuilderSerializationTests.java index 74838a112c98c..0cb1dec4a63ab 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/inference/ltr/LearningToRankRescorerBuilderSerializationTests.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/inference/ltr/LearningToRankRescorerBuilderSerializationTests.java @@ -187,16 +187,15 @@ protected Writeable.Reader instanceReader() { return in -> new LearningToRankRescorerBuilder(in, learningToRankService); } - protected LearningToRankRescorerBuilder createTestInstance(int windowSize) { LearningToRankRescorerBuilder builder = randomBoolean() ? createXContextTestInstance(null) : new LearningToRankRescorerBuilder( - randomAlphaOfLength(10), - randomLearningToRankConfig(), - randomBoolean() ? randomParams() : null, - learningToRankService - ); + randomAlphaOfLength(10), + randomLearningToRankConfig(), + randomBoolean() ? randomParams() : null, + learningToRankService + ); builder.windowSize(windowSize);