Skip to content

Commit

Permalink
Added deprecation warning for rescore in scroll queries (#33070)
Browse files Browse the repository at this point in the history
This adds a deprecation warning for using rescore on scroll queries in 6.x. As per #31775 we will not be supporting this going forward.

See also #32918 which implements the validation error for 7.0
  • Loading branch information
not-napoleon authored Aug 29, 2018
1 parent 95022af commit 7d4895d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
11 changes: 11 additions & 0 deletions docs/reference/migration/migrate_6_5.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ This section discusses the changes that you need to be aware of when migrating
your application to Elasticsearch 6.5.

* <<breaking_65_logging_changes>>
* <<breaking_65_search_changes>>
* <<breaking_65_sql_changes>>

See also <<release-highlights>> and <<es-release-notes>>.
Expand All @@ -25,6 +26,16 @@ will not change the logging configuration files though. You should make this
change before 7.0 because in 7.0 Elasticsearch will no longer automatically
add the node name to the logging configuration if it isn't already present.

[[breaking_65_search_changes]]
=== Search changes

==== Scroll

Using `rescore` with a scroll query now raises a deprecation warning and
ignores the parameter. In earlier 6.x releases, rescore on scroll queries was
silently ignored. In 7.0 and later, we will return a `400 - Bad Request` with
a validation error.

[[breaking_65_sql_changes]]
=== SQL plugin changes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ public ActionRequestValidationException validate() {
if (source != null && source.size() == 0 && scroll != null) {
validationException = addValidationError("[size] cannot be [0] in a scroll context", validationException);
}
if (source != null && source.rescores() != null && source.rescores().isEmpty() == false && scroll != null) {
DEPRECATION_LOGGER.deprecated("Using [rescore] for a scroll query is deprecated and will be ignored. From 7.0 on will " +
"return a 400 error");
}
return validationException;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.util.ArrayUtils;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.search.rescore.QueryRescorerBuilder;

import java.io.IOException;
import java.util.ArrayList;
Expand Down Expand Up @@ -124,6 +126,17 @@ public void testValidate() throws IOException {
assertEquals(1, validationErrors.validationErrors().size());
assertEquals("[size] cannot be [0] in a scroll context", validationErrors.validationErrors().get(0));
}
{
// Rescore is deprecated on scroll requests
SearchRequest searchRequest = createSearchRequest().source(new SearchSourceBuilder());
searchRequest.source().addRescorer(new QueryRescorerBuilder(QueryBuilders.matchAllQuery()));
searchRequest.requestCache(false);
searchRequest.scroll(new TimeValue(1000));
ActionRequestValidationException validationErrors = searchRequest.validate();
assertNull(validationErrors);
assertWarnings("Using [rescore] for a scroll query is deprecated and will be ignored. From 7.0 on will return a 400 error");
}

}

public void testEqualsAndHashcode() throws IOException {
Expand Down

0 comments on commit 7d4895d

Please sign in to comment.