8
8
import org .elasticsearch .action .ActionRequest ;
9
9
import org .elasticsearch .action .ActionRequestValidationException ;
10
10
import org .elasticsearch .action .search .SearchRequest ;
11
+ import org .elasticsearch .common .Strings ;
11
12
import org .elasticsearch .common .io .stream .StreamInput ;
12
13
import org .elasticsearch .common .io .stream .StreamOutput ;
13
14
import org .elasticsearch .common .unit .TimeValue ;
21
22
import java .util .Objects ;
22
23
23
24
import static org .elasticsearch .action .ValidateActions .addValidationError ;
25
+ import static org .elasticsearch .action .search .SearchRequest .FORMAT_PARAMS ;
24
26
25
27
/**
26
28
* A request to track asynchronously the progress of a search against one or more indices.
27
29
*
28
30
* @see AsyncSearchResponse
29
31
*/
30
32
public class SubmitAsyncSearchRequest extends ActionRequest {
31
- public static long MIN_KEEP_ALIVE = TimeValue .timeValueHours (1 ).millis ();
33
+ public static long MIN_KEEP_ALIVE = TimeValue .timeValueMinutes (1 ).millis ();
32
34
33
35
private TimeValue waitForCompletion = TimeValue .timeValueSeconds (1 );
34
36
private boolean cleanOnCompletion = true ;
@@ -128,22 +130,26 @@ public boolean isCleanOnCompletion() {
128
130
public ActionRequestValidationException validate () {
129
131
ActionRequestValidationException validationException = request .validate ();
130
132
if (request .scroll () != null ) {
131
- addValidationError ("scroll queries are not supported" , validationException );
133
+ addValidationError ("[ scroll] queries are not supported" , validationException );
132
134
}
133
135
if (request .isSuggestOnly ()) {
134
136
validationException = addValidationError ("suggest-only queries are not supported" , validationException );
135
137
}
136
138
if (keepAlive .getMillis () < MIN_KEEP_ALIVE ) {
137
139
validationException =
138
- addValidationError ("keep_alive must be greater than 1 minute, got:" + keepAlive .toString (), validationException );
140
+ addValidationError ("[keep_alive] must be greater than 1 minute, got:" + keepAlive .toString (), validationException );
141
+ }
142
+ if (request .isCcsMinimizeRoundtrips ()) {
143
+ validationException =
144
+ addValidationError ("[ccs_minimize_roundtrips] is not supported on async search queries" , validationException );
139
145
}
140
146
141
147
return validationException ;
142
148
}
143
149
144
150
@ Override
145
151
public Task createTask (long id , String type , String action , TaskId parentTaskId , Map <String , String > headers ) {
146
- return new CancellableTask (id , type , action , "" , parentTaskId , headers ) {
152
+ return new CancellableTask (id , type , action , toString () , parentTaskId , headers ) {
147
153
@ Override
148
154
public boolean shouldCancelChildrenOnCancellation () {
149
155
return true ;
@@ -166,4 +172,14 @@ public boolean equals(Object o) {
166
172
public int hashCode () {
167
173
return Objects .hash (waitForCompletion , cleanOnCompletion , keepAlive , request );
168
174
}
175
+
176
+ @ Override
177
+ public String toString () {
178
+ return "SubmitAsyncSearchRequest{" +
179
+ "waitForCompletion=" + waitForCompletion +
180
+ ", cleanOnCompletion=" + cleanOnCompletion +
181
+ ", keepAlive=" + keepAlive +
182
+ ", request=" + request +
183
+ '}' ;
184
+ }
169
185
}
0 commit comments