Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -161,17 +161,21 @@ public void writeTo(StreamOutput out) throws IOException {
@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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ public void testIllegalArguments() {
}

public void testValidate() throws IOException {

{
// if scroll isn't set, validate should never add errors
SearchRequest searchRequest = createSearchRequest().source(new SearchSourceBuilder());
Expand Down Expand Up @@ -114,6 +113,16 @@ public void testValidate() throws IOException {
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,30 @@
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
request_cache: true
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