File tree Expand file tree Collapse file tree 3 files changed +24
-0
lines changed
docs/reference/migration/migrate_7_0
main/java/org/elasticsearch/action/search
test/java/org/elasticsearch/search Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,13 @@ Setting `request_cache:true` on a query that creates a scroll (`scroll=1m`)
5454has been deprecated in 6 and will now return a `400 - Bad request`.
5555Scroll queries are not meant to be cached.
5656
57+ ==== Scroll queries cannot use `rescore` anymore
58+ Including a rescore clause on a query that creates a scroll (`scroll=1m`) has
59+ been deprecated in 6.5 and will now return a `400 - Bad request`. Allowing
60+ rescore on scroll queries would break the scroll sort. In the 6.x line, the
61+ rescore clause was silently ignored (for scroll queries), and it was allowed in
62+ the 5.x line.
63+
5764==== Term Suggesters supported distance algorithms
5865
5966The following string distance algorithms were given additional names in 6.2 and
Original file line number Diff line number Diff line change @@ -184,6 +184,10 @@ public ActionRequestValidationException validate() {
184184 if (source != null && source .size () == 0 && scroll != null ) {
185185 validationException = addValidationError ("[size] cannot be [0] in a scroll context" , validationException );
186186 }
187+ if (source != null && source .rescores () != null && source .rescores ().isEmpty () == false && scroll != null ) {
188+ validationException =
189+ addValidationError ("using [rescore] is not allowed in a scroll context" , validationException );
190+ }
187191 return validationException ;
188192 }
189193
Original file line number Diff line number Diff line change 2828import org .elasticsearch .common .io .stream .StreamInput ;
2929import org .elasticsearch .common .unit .TimeValue ;
3030import org .elasticsearch .common .util .ArrayUtils ;
31+ import org .elasticsearch .index .query .QueryBuilders ;
3132import org .elasticsearch .search .builder .SearchSourceBuilder ;
33+ import org .elasticsearch .search .rescore .QueryRescorerBuilder ;
3234
3335import java .io .IOException ;
3436import java .util .ArrayList ;
@@ -123,6 +125,17 @@ public void testValidate() throws IOException {
123125 assertEquals (1 , validationErrors .validationErrors ().size ());
124126 assertEquals ("[size] cannot be [0] in a scroll context" , validationErrors .validationErrors ().get (0 ));
125127 }
128+ {
129+ // Rescore is not allowed on scroll requests
130+ SearchRequest searchRequest = createSearchRequest ().source (new SearchSourceBuilder ());
131+ searchRequest .source ().addRescorer (new QueryRescorerBuilder (QueryBuilders .matchAllQuery ()));
132+ searchRequest .requestCache (false );
133+ searchRequest .scroll (new TimeValue (1000 ));
134+ ActionRequestValidationException validationErrors = searchRequest .validate ();
135+ assertNotNull (validationErrors );
136+ assertEquals (1 , validationErrors .validationErrors ().size ());
137+ assertEquals ("using [rescore] is not allowed in a scroll context" , validationErrors .validationErrors ().get (0 ));
138+ }
126139 }
127140
128141 public void testEqualsAndHashcode () throws IOException {
You can’t perform that action at this time.
0 commit comments