Skip to content
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

Added deprecation warning for rescore in scroll queries #33070

Merged
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
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