parent
55b71a871b
commit
7a27a2770b
|
@ -161,17 +161,21 @@ public final class SearchRequest extends ActionRequest implements IndicesRequest
|
|||
@Override
|
||||
public ActionRequestValidationException validate() {
|
||||
ActionRequestValidationException validationException = null;
|
||||
if (source != null && source.trackTotalHits() == false && scroll() != null) {
|
||||
final Scroll scroll = scroll();
|
||||
if (source != null && source.trackTotalHits() == false && scroll != null) {
|
||||
validationException =
|
||||
addValidationError("disabling [track_total_hits] is not allowed in a scroll context", validationException);
|
||||
}
|
||||
if (source != null && source.from() > 0 && scroll() != null) {
|
||||
if (source != null && source.from() > 0 && scroll != null) {
|
||||
validationException =
|
||||
addValidationError("using [from] is not allowed in a scroll context", validationException);
|
||||
}
|
||||
if (requestCache != null && requestCache && scroll() != null) {
|
||||
if (requestCache != null && requestCache && scroll != null) {
|
||||
validationException =
|
||||
addValidationError("[request_cache] cannot be used in a a scroll context", validationException);
|
||||
addValidationError("[request_cache] cannot be used in a scroll context", validationException);
|
||||
}
|
||||
if (source != null && source.size() == 0 && scroll != null) {
|
||||
validationException = addValidationError("[size] cannot be [0] in a scroll context", validationException);
|
||||
}
|
||||
return validationException;
|
||||
}
|
||||
|
|
|
@ -82,7 +82,6 @@ public class SearchRequestTests extends AbstractSearchTestCase {
|
|||
}
|
||||
|
||||
public void testValidate() throws IOException {
|
||||
|
||||
{
|
||||
// if scroll isn't set, validate should never add errors
|
||||
SearchRequest searchRequest = createSearchRequest().source(new SearchSourceBuilder());
|
||||
|
@ -114,6 +113,16 @@ public class SearchRequestTests extends AbstractSearchTestCase {
|
|||
assertEquals(1, validationErrors.validationErrors().size());
|
||||
assertEquals("using [from] is not allowed in a scroll context", validationErrors.validationErrors().get(0));
|
||||
}
|
||||
{
|
||||
// scroll and `size` is `0`
|
||||
SearchRequest searchRequest = createSearchRequest().source(new SearchSourceBuilder().size(0));
|
||||
searchRequest.requestCache(false);
|
||||
searchRequest.scroll(new TimeValue(1000));
|
||||
ActionRequestValidationException validationErrors = searchRequest.validate();
|
||||
assertNotNull(validationErrors);
|
||||
assertEquals(1, validationErrors.validationErrors().size());
|
||||
assertEquals("[size] cannot be [0] in a scroll context", validationErrors.validationErrors().get(0));
|
||||
}
|
||||
}
|
||||
|
||||
public void testEqualsAndHashcode() throws IOException {
|
||||
|
|
|
@ -206,7 +206,7 @@
|
|||
indices.create:
|
||||
index: test_scroll
|
||||
- do:
|
||||
catch: /\[request_cache\] cannot be used in a a scroll context/
|
||||
catch: /\[request_cache\] cannot be used in a scroll context/
|
||||
search:
|
||||
index: test_scroll
|
||||
scroll: 1m
|
||||
|
@ -214,3 +214,22 @@
|
|||
body:
|
||||
query:
|
||||
match_all: {}
|
||||
|
||||
---
|
||||
"Scroll with size 0":
|
||||
- skip:
|
||||
version: " - 6.99.99"
|
||||
reason: the error message has been added in v7.0.0
|
||||
- do:
|
||||
indices.create:
|
||||
index: test_scroll
|
||||
- do:
|
||||
catch: /\[size\] cannot be \[0\] in a scroll context/
|
||||
search:
|
||||
index: test_scroll
|
||||
scroll: 1m
|
||||
request_cache: true
|
||||
body:
|
||||
query:
|
||||
match_all: {}
|
||||
size: 0
|
||||
|
|
Loading…
Reference in New Issue