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`)
54
54
has been deprecated in 6 and will now return a `400 - Bad request`.
55
55
Scroll queries are not meant to be cached.
56
56
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
+
57
64
==== Term Suggesters supported distance algorithms
58
65
59
66
The 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() {
184
184
if (source != null && source .size () == 0 && scroll != null ) {
185
185
validationException = addValidationError ("[size] cannot be [0] in a scroll context" , validationException );
186
186
}
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
+ }
187
191
return validationException ;
188
192
}
189
193
Original file line number Diff line number Diff line change 28
28
import org .elasticsearch .common .io .stream .StreamInput ;
29
29
import org .elasticsearch .common .unit .TimeValue ;
30
30
import org .elasticsearch .common .util .ArrayUtils ;
31
+ import org .elasticsearch .index .query .QueryBuilders ;
31
32
import org .elasticsearch .search .builder .SearchSourceBuilder ;
33
+ import org .elasticsearch .search .rescore .QueryRescorerBuilder ;
32
34
33
35
import java .io .IOException ;
34
36
import java .util .ArrayList ;
@@ -123,6 +125,17 @@ public void testValidate() throws IOException {
123
125
assertEquals (1 , validationErrors .validationErrors ().size ());
124
126
assertEquals ("[size] cannot be [0] in a scroll context" , validationErrors .validationErrors ().get (0 ));
125
127
}
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
+ }
126
139
}
127
140
128
141
public void testEqualsAndHashcode () throws IOException {
You can’t perform that action at this time.
0 commit comments