mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-25 09:28:27 +00:00
When the parameter `max_docs` is less than `slices` in update_by_query, delete_by_query or reindex API, `max_docs ` is set to 0 and we throw an action_request_validation_exception with confused error message: "maxDocs should be greater than 0...". This change checks that whether `max_docs` is less than `slices` and throw an illegal_argument_exception with clear message. Relates to #52786. Co-authored-by: bellengao <gbl_long@163.com>
This commit is contained in:
parent
d8928b3f48
commit
8427d677e9
@ -87,6 +87,27 @@
|
||||
query:
|
||||
match_all: {}
|
||||
|
||||
---
|
||||
"max_docs shoule be greater than slices":
|
||||
- skip:
|
||||
version: " - 7.2.99"
|
||||
reason: "max_docs introduced in 7.3.0"
|
||||
|
||||
- do:
|
||||
index:
|
||||
index: test
|
||||
id: 1
|
||||
body: { "text": "test" }
|
||||
- do:
|
||||
catch: /\[max_docs\] should be >= \[slices\]/
|
||||
delete_by_query:
|
||||
index: test
|
||||
max_docs: 1
|
||||
slices: 2
|
||||
body:
|
||||
query:
|
||||
match_all: {}
|
||||
|
||||
---
|
||||
"invalid scroll_size fails":
|
||||
- do:
|
||||
|
@ -132,6 +132,28 @@
|
||||
index: dest
|
||||
max_docs: -4
|
||||
|
||||
---
|
||||
"max_docs shoule be greater than slices":
|
||||
- skip:
|
||||
version: " - 7.2.99"
|
||||
reason: "max_docs introduced in 7.3.0"
|
||||
|
||||
- do:
|
||||
index:
|
||||
index: test
|
||||
id: 1
|
||||
body: { "text": "test" }
|
||||
- do:
|
||||
catch: /\[max_docs\] should be >= \[slices\]/
|
||||
reindex:
|
||||
max_docs: 1
|
||||
slices: 2
|
||||
body:
|
||||
source:
|
||||
index: test
|
||||
dest:
|
||||
index: dest
|
||||
|
||||
---
|
||||
"invalid max_docs in URL fails":
|
||||
- skip:
|
||||
|
@ -101,6 +101,24 @@
|
||||
query:
|
||||
match_all: {}
|
||||
|
||||
---
|
||||
"max_docs shoule be greater than slices":
|
||||
- skip:
|
||||
version: " - 7.2.99"
|
||||
reason: "max_docs introduced in 7.3.0"
|
||||
|
||||
- do:
|
||||
index:
|
||||
index: test
|
||||
id: 1
|
||||
body: { "text": "test" }
|
||||
- do:
|
||||
catch: /\[max_docs\] should be >= \[slices\]/
|
||||
update_by_query:
|
||||
index: test
|
||||
max_docs: 1
|
||||
slices: 2
|
||||
|
||||
---
|
||||
"invalid scroll_size fails":
|
||||
- do:
|
||||
|
@ -214,6 +214,9 @@ public abstract class AbstractBulkByScrollRequest<Self extends AbstractBulkByScr
|
||||
if (maxDocs < 0) {
|
||||
throw new IllegalArgumentException("[max_docs] parameter cannot be negative, found [" + maxDocs + "]");
|
||||
}
|
||||
if (maxDocs < slices) {
|
||||
throw new IllegalArgumentException("[max_docs] should be >= [slices]");
|
||||
}
|
||||
this.maxDocs = maxDocs;
|
||||
return self();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user