Skip to content

Commit 4226d83

Browse files
authored
Msearch template API tests (#735)
* added msearch template tests Signed-off-by: Tokesh <[email protected]> * lint fix Signed-off-by: Tokesh <[email protected]> * added core msearch template tests Signed-off-by: Tokesh <[email protected]> * added msearch get tests Signed-off-by: Tokesh <[email protected]> * renaming folders, using multiple methods, deleting default code Signed-off-by: Tokesh <[email protected]> --------- Signed-off-by: Tokesh <[email protected]> Signed-off-by: Niyazbek Torekeldi <[email protected]>
1 parent b9e9c01 commit 4226d83

File tree

6 files changed

+86
-39
lines changed

6 files changed

+86
-39
lines changed

Diff for: CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
7575
- Fixed request schema for `PATCH /_plugins/_security/api/nodesdn` ([#731](https://github.com/opensearch-project/opensearch-api-specification/pull/731))
7676
- Fixed response schema for `GET /_plugins/_security/api/nodesdn/{cluster_name}` ([#731](https://github.com/opensearch-project/opensearch-api-specification/pull/731))
7777
- Fixed request body for `/_search/scroll/{scroll_id}` ([#732](https://github.com/opensearch-project/opensearch-api-specification/pull/732))
78+
- Fixed type in `_msearch/template` ([#735](https://github.com/opensearch-project/opensearch-api-specification/pull/735))
7879

7980
### Changed
8081
- Changed `tasks._common:TaskInfo` and `tasks._common:TaskGroup` to be composed of a `tasks._common:TaskInfoBase` ([#683](https://github.com/opensearch-project/opensearch-api-specification/pull/683))

Diff for: spec/schemas/_core.msearch_template.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ components:
2525
The value is the variable value.
2626
type: object
2727
additionalProperties:
28-
type: object
28+
oneOf:
29+
- type: string
30+
- type: object
2931
profile:
3032
description: When `true`, provides a profile for the query execution.
3133
type: boolean

Diff for: tests/default/_core/msearch.yaml renamed to tests/default/_core/msearch/index.yaml

+5-33
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
$schema: ../../../json_schemas/test_story.schema.yaml
1+
$schema: ../../../../json_schemas/test_story.schema.yaml
22

33
description: Test document multi-search.
44
epilogues:
@@ -25,7 +25,9 @@ prologues:
2525
chapters:
2626
- synopsis: Run multiple search requests in single request (GET).
2727
path: /_msearch
28-
method: GET
28+
method:
29+
- GET
30+
- POST
2931
request:
3032
content_type: application/x-ndjson
3133
payload:
@@ -52,34 +54,4 @@ chapters:
5254
- _index: movies
5355
_id: movie1
5456
- _index: movies
55-
_id: movie2
56-
- synopsis: Run multiple search requests in single request (POST).
57-
path: /_msearch
58-
method: POST
59-
request:
60-
content_type: application/x-ndjson
61-
payload:
62-
- {index: movies}
63-
- {query: {match_all: {}}}
64-
- {index: books}
65-
- {query: {match_all: {}}}
66-
response:
67-
status: 200
68-
payload:
69-
responses:
70-
- hits:
71-
total:
72-
value: 2
73-
relation: eq
74-
hits:
75-
- _index: movies
76-
_id: movie1
77-
- _index: movies
78-
_id: movie2
79-
- hits:
80-
total:
81-
value: 1
82-
relation: eq
83-
hits:
84-
- _index: books
85-
_id: book1
57+
_id: movie2

Diff for: tests/default/_core/msearch/template.yaml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
$schema: ../../../../json_schemas/test_story.schema.yaml
2+
3+
description: Test _msearch/template APIs.
4+
prologues:
5+
- path: /_bulk
6+
method: POST
7+
parameters:
8+
refresh: true
9+
request:
10+
content_type: application/x-ndjson
11+
payload:
12+
- {create: {_index: books, _id: book1}}
13+
- {author: Harper Lee, title: To Kill a Mockingbird, year: 1960}
14+
- {create: {_index: books, _id: book2}}
15+
- {author: Elizabeth Rudnick, title: Beauty and the Beast, year: 1991}
16+
- {create: {_index: books, _id: book3}}
17+
- {author: George Orwell, title: '1984', year: 1949}
18+
epilogues:
19+
- path: /books
20+
method: DELETE
21+
status: [200, 404]
22+
23+
chapters:
24+
- synopsis: Perform a multi-search template query using a GET request.
25+
path: /_msearch/template
26+
method:
27+
- GET
28+
- POST
29+
request:
30+
content_type: application/x-ndjson
31+
payload:
32+
- {index: books}
33+
- {source: '{"query": {"match": {"title": "{{title}}"}}}', params: {title: Mockingbird}}
34+
- {index: books}
35+
- {source: '{"query": {"match": {"title": "{{title}}"}}}', params: {title: Beast}}

Diff for: tests/default/indices/msearch.yaml renamed to tests/default/indices/msearch/index.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
$schema: ../../../json_schemas/test_story.schema.yaml
1+
$schema: ../../../../json_schemas/test_story.schema.yaml
22

33
description: Test endpoints relevant to the lifecycle of an index, including multi-get and multi-search operations.
44
prologues:
@@ -22,7 +22,9 @@ epilogues:
2222
chapters:
2323
- synopsis: Perform a `_msearch` request to execute multiple search queries in a single call.
2424
path: /{index}/_msearch
25-
method: POST
25+
method:
26+
- GET
27+
- POST
2628
parameters:
2729
index: books
2830
request:
@@ -31,6 +33,4 @@ chapters:
3133
- {index: books}
3234
- {query: {match: {title: To Kill a Mockingbird}}}
3335
- {index: books}
34-
- {query: {match: {title: The Cruise}}}
35-
response:
36-
status: 200
36+
- {query: {match: {title: The Cruise}}}

Diff for: tests/default/indices/msearch/template.yaml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
$schema: ../../../../json_schemas/test_story.schema.yaml
2+
3+
description: Test _msearch/template APIs.
4+
prologues:
5+
- path: /_bulk
6+
method: POST
7+
parameters:
8+
refresh: true
9+
request:
10+
content_type: application/x-ndjson
11+
payload:
12+
- {create: {_index: books, _id: book1}}
13+
- {author: Harper Lee, title: To Kill a Mockingbird, year: 1960}
14+
- {create: {_index: books, _id: book2}}
15+
- {author: Elizabeth Rudnick, title: Beauty and the Beast, year: 1991}
16+
- {create: {_index: books, _id: book3}}
17+
- {author: George Orwell, title: '1984', year: 1949}
18+
epilogues:
19+
- path: /books
20+
method: DELETE
21+
status: [200, 404]
22+
23+
chapters:
24+
- synopsis: Perform a multi-search template query using a GET request.
25+
path: /{index}/_msearch/template
26+
parameters:
27+
index: books
28+
method:
29+
- GET
30+
- POST
31+
request:
32+
content_type: application/x-ndjson
33+
payload:
34+
- {index: books}
35+
- {source: '{"query": {"match": {"title": "{{title}}"}}}', params: {title: Mockingbird}}
36+
- {index: books}
37+
- {source: '{"query": {"match": {"title": "{{title}}"}}}', params: {title: Beast}}

0 commit comments

Comments
 (0)