forked from opensearch-project/OpenSearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix from and size parameter can be negative when searching (opensearc…
…h-project#13047) * Fix from and size parameter can be negative when searching Signed-off-by: Gao Binlong <gbinlong@amazon.com> * Add changelog Signed-off-by: Gao Binlong <gbinlong@amazon.com> * fix test failure Signed-off-by: Gao Binlong <gbinlong@amazon.com> * Fix test failure Signed-off-by: Gao Binlong <gbinlong@amazon.com> * Optimize the code Signed-off-by: Gao Binlong <gbinlong@amazon.com> --------- Signed-off-by: Gao Binlong <gbinlong@amazon.com>
- Loading branch information
1 parent
f41db2c
commit ab7e914
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.99.99" | ||
reason: "fixed in 3.0.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.99.99" | ||
reason: "fixed in 3.0.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