-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Backport 2.x] Fix from and size parameter can be negative when searc…
…hing (#13047) (#13361) * Fix from and size parameter can be negative when searching (#13047) * Fix from and size parameter can be negative when searching Signed-off-by: Gao Binlong <[email protected]> * Add changelog Signed-off-by: Gao Binlong <[email protected]> * fix test failure Signed-off-by: Gao Binlong <[email protected]> * Fix test failure Signed-off-by: Gao Binlong <[email protected]> * Optimize the code Signed-off-by: Gao Binlong <[email protected]> --------- Signed-off-by: Gao Binlong <[email protected]> (cherry picked from commit ab7e914) * Update support version Signed-off-by: Gao Binlong <[email protected]> * Small change to rerun gradle check Signed-off-by: Gao Binlong <[email protected]> --------- Signed-off-by: Gao Binlong <[email protected]>
- Loading branch information
1 parent
3d26a6f
commit 4378edd
Showing
6 changed files
with
161 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 113 additions & 0 deletions
113
rest-api-spec/src/main/resources/rest-api-spec/test/search/360_from_and_size.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
setup: | ||
- do: | ||
indices.create: | ||
index: test_1 | ||
- do: | ||
index: | ||
index: test_1 | ||
id: 1 | ||
body: { foo: bar } | ||
- do: | ||
index: | ||
index: test_1 | ||
id: 2 | ||
body: { foo: bar } | ||
- do: | ||
index: | ||
index: test_1 | ||
id: 3 | ||
body: { foo: bar } | ||
|
||
- do: | ||
index: | ||
index: test_1 | ||
id: 4 | ||
body: { foo: bar } | ||
- do: | ||
indices.refresh: | ||
index: [test_1] | ||
|
||
--- | ||
teardown: | ||
- do: | ||
indices.delete: | ||
index: test_1 | ||
ignore: 404 | ||
|
||
--- | ||
"Throws exception if from or size query parameter is negative": | ||
- skip: | ||
version: " - 2.13.99" | ||
reason: "fixed in 2.14.0" | ||
- do: | ||
catch: '/\[from\] parameter cannot be negative, found \[-5\]/' | ||
search: | ||
index: test_1 | ||
from: -5 | ||
size: 10 | ||
body: | ||
query: | ||
match: | ||
foo: bar | ||
|
||
- do: | ||
catch: '/\[size\] parameter cannot be negative, found \[-1\]/' | ||
search: | ||
index: test_1 | ||
from: 0 | ||
size: -1 | ||
body: | ||
query: | ||
match: | ||
foo: bar | ||
|
||
- do: | ||
search: | ||
index: test_1 | ||
from: 0 | ||
size: 10 | ||
body: | ||
query: | ||
match: | ||
foo: bar | ||
|
||
- match: {hits.total.value: 4} | ||
|
||
--- | ||
"Throws exception if from or size request body parameter is negative": | ||
- skip: | ||
version: " - 2.13.99" | ||
reason: "fixed in 2.14.0" | ||
- do: | ||
catch: '/\[from\] parameter cannot be negative, found \[-5\]/' | ||
search: | ||
index: test_1 | ||
body: | ||
from: -5 | ||
size: 10 | ||
query: | ||
match: | ||
foo: bar | ||
|
||
- do: | ||
catch: '/\[size\] parameter cannot be negative, found \[-1\]/' | ||
search: | ||
index: test_1 | ||
body: | ||
from: 0 | ||
size: -1 | ||
query: | ||
match: | ||
foo: bar | ||
|
||
- do: | ||
search: | ||
index: test_1 | ||
body: | ||
from: 0 | ||
size: 10 | ||
query: | ||
match: | ||
foo: bar | ||
|
||
- match: {hits.total.value: 4} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters