diff --git a/tests/default/indices/mapping.yaml b/tests/default/indices/mapping.yaml index f22dc2d4c..e69de29bb 100644 --- a/tests/default/indices/mapping.yaml +++ b/tests/default/indices/mapping.yaml @@ -1,185 +0,0 @@ -$schema: ../../../json_schemas/test_story.schema.yaml - -description: Test mappings endpoints. -prologues: - - path: /{index} - method: PUT - parameters: - index: games - - path: /{index} - method: PUT - parameters: - index: movies - request: - payload: - mappings: - properties: - director: - type: text - year: - type: integer - location: - type: ip - ignore_malformed: true -epilogues: - - path: /movies,games - method: DELETE - status: [200, 404] -chapters: - - synopsis: Get mappings for an index. - path: /{index}/_mapping - method: GET - parameters: - index: movies - response: - status: 200 - payload: - movies: - mappings: - properties: - director: - type: text - year: - type: integer - - synopsis: Get mappings for multiple indexes. - path: /{index}/_mapping - method: GET - parameters: - index: movies,games - response: - status: 200 - payload: - movies: - mappings: - properties: - director: - type: text - year: - type: integer - games: - mappings: {} - - synopsis: Update mapping for an index. - path: /{index}/_mapping - method: PUT - parameters: - index: movies - allow_no_indices: true - expand_wildcards: all - ignore_unavailable: true - timeout: 10s - write_index_only: true - request: - payload: - dynamic: 'true' - properties: - producer: - type: text - response: - status: 200 - payload: - acknowledged: true - - synopsis: Update mapping for an index (cluster_manager_timeout). - path: /{index}/_mapping - method: PUT - version: '>= 2.0' - parameters: - index: movies - cluster_manager_timeout: 1s - request: - payload: - properties: - producer: - type: text - response: - status: 200 - payload: - acknowledged: true - - synopsis: Update mapping for an index with setting dynamic to false. - path: /{index}/_mapping - method: PUT - parameters: - index: movies - allow_no_indices: true - expand_wildcards: all - ignore_unavailable: true - timeout: 10s - write_index_only: true - request: - payload: - dynamic: 'false' - response: - status: 200 - payload: - acknowledged: true - - synopsis: Update mapping for an index with setting dynamic to strict. - path: /{index}/_mapping - method: PUT - parameters: - index: movies - allow_no_indices: true - expand_wildcards: all - ignore_unavailable: true - timeout: 10s - write_index_only: true - request: - payload: - dynamic: strict - response: - status: 200 - payload: - acknowledged: true - - synopsis: Update mapping for an index with setting dynamic to strict_allow_templates. - version: '>= 2.16' - path: /{index}/_mapping - method: PUT - parameters: - index: movies - allow_no_indices: true - expand_wildcards: all - ignore_unavailable: true - timeout: 10s - write_index_only: true - request: - payload: - dynamic: strict_allow_templates - response: - status: 200 - payload: - acknowledged: true - - synopsis: Add new fields to index mapping. - path: /{index}/_mapping - method: POST - parameters: - index: movies - request: - payload: - properties: - genre: - type: text - rating: - type: float - response: - status: 200 - payload: - acknowledged: true - - synopsis: Get specific field mappings for an index. - path: /{index}/_mapping/field/{fields} - method: GET - parameters: - index: movies - fields: director,year - response: - status: 200 - payload: - movies: - mappings: - year: - full_name: year - mapping: - year: - type: integer - director: - full_name: director - mapping: - director: - type: text diff --git a/tests/default/indices/mapping/field.yaml b/tests/default/indices/mapping/field.yaml new file mode 100644 index 000000000..5037e2ec3 --- /dev/null +++ b/tests/default/indices/mapping/field.yaml @@ -0,0 +1,61 @@ +$schema: ../../../../json_schemas/test_story.schema.yaml + +description: Test specific field mappings endpoints. +prologues: + - path: /{index} + method: PUT + parameters: + index: movies + request: + payload: + mappings: + properties: + director: + type: text + year: + type: integer + location: + type: ip + ignore_malformed: true +epilogues: + - path: /movies + method: DELETE + status: [200, 404] +chapters: + - synopsis: Add new fields to index mapping. + path: /{index}/_mapping + method: POST + parameters: + index: movies + request: + payload: + properties: + genre: + type: text + rating: + type: float + response: + status: 200 + payload: + acknowledged: true + - synopsis: Get specific field mappings for an index. + path: /{index}/_mapping/field/{fields} + method: GET + parameters: + index: movies + fields: director,year + response: + status: 200 + payload: + movies: + mappings: + year: + full_name: year + mapping: + year: + type: integer + director: + full_name: director + mapping: + director: + type: text diff --git a/tests/default/indices/mapping/index.yaml b/tests/default/indices/mapping/index.yaml new file mode 100644 index 000000000..35a74eeea --- /dev/null +++ b/tests/default/indices/mapping/index.yaml @@ -0,0 +1,148 @@ +$schema: ../../../../json_schemas/test_story.schema.yaml + +description: Test mappings endpoints. +prologues: + - path: /{index} + method: PUT + parameters: + index: games + - path: /{index} + method: PUT + parameters: + index: movies + request: + payload: + mappings: + properties: + director: + type: text + year: + type: integer + location: + type: ip + ignore_malformed: true +epilogues: + - path: /movies,games + method: DELETE + status: [200, 404] +chapters: + - synopsis: Get mappings for an index. + path: /{index}/_mapping + method: GET + parameters: + index: movies + response: + status: 200 + payload: + movies: + mappings: + properties: + director: + type: text + year: + type: integer + - synopsis: Get mappings for multiple indexes. + path: /{index}/_mapping + method: GET + parameters: + index: movies,games + response: + status: 200 + payload: + movies: + mappings: + properties: + director: + type: text + year: + type: integer + games: + mappings: {} + - synopsis: Update mapping for an index. + path: /{index}/_mapping + method: PUT + parameters: + index: movies + allow_no_indices: true + expand_wildcards: all + ignore_unavailable: true + timeout: 10s + write_index_only: true + request: + payload: + dynamic: 'true' + properties: + producer: + type: text + response: + status: 200 + payload: + acknowledged: true + - synopsis: Update mapping for an index (cluster_manager_timeout). + path: /{index}/_mapping + method: PUT + version: '>= 2.0' + parameters: + index: movies + cluster_manager_timeout: 1s + request: + payload: + properties: + producer: + type: text + response: + status: 200 + payload: + acknowledged: true + - synopsis: Update mapping for an index with setting dynamic to false. + path: /{index}/_mapping + method: PUT + parameters: + index: movies + allow_no_indices: true + expand_wildcards: all + ignore_unavailable: true + timeout: 10s + write_index_only: true + request: + payload: + dynamic: 'false' + response: + status: 200 + payload: + acknowledged: true + - synopsis: Update mapping for an index with setting dynamic to strict. + path: /{index}/_mapping + method: PUT + parameters: + index: movies + allow_no_indices: true + expand_wildcards: all + ignore_unavailable: true + timeout: 10s + write_index_only: true + request: + payload: + dynamic: strict + response: + status: 200 + payload: + acknowledged: true + - synopsis: Update mapping for an index with setting dynamic to strict_allow_templates. + version: '>= 2.16' + path: /{index}/_mapping + method: PUT + parameters: + index: movies + allow_no_indices: true + expand_wildcards: all + ignore_unavailable: true + timeout: 10s + write_index_only: true + request: + payload: + dynamic: strict_allow_templates + response: + status: 200 + payload: + acknowledged: true \ No newline at end of file diff --git a/tests/default/indices/msearch.yaml b/tests/default/indices/msearch.yaml index 33170668c..9d97fc6aa 100644 --- a/tests/default/indices/msearch.yaml +++ b/tests/default/indices/msearch.yaml @@ -1,106 +1,25 @@ $schema: ../../../json_schemas/test_story.schema.yaml description: Test endpoints relevant to the lifecycle of an index, including multi-get and multi-search operations. +prologues: + - path: /_bulk + method: POST + parameters: + refresh: true + request: + content_type: application/x-ndjson + payload: + - {create: {_index: books, _id: book1}} + - {author: Harper Lee, title: To Kill a Mockingbird, year: 60} + - {create: {_index: movies, _id: movie1}} + - {director: Bennett Miller, title: The Cruise, year: 1998} + - {create: {_index: movies, _id: movie2}} + - {director: Nicolas Winding Refn, title: Drive, year: 1960} epilogues: - path: /books method: DELETE status: [200, 404] - - path: /games - method: DELETE - status: [200, 404] chapters: - - synopsis: Create an index named `books` with mappings and settings. - path: /{index} - method: PUT - parameters: - index: books - request: - payload: - mappings: - properties: - name: - type: keyword - age: - type: integer - settings: - number_of_shards: 5 - number_of_replicas: 2 - response: - status: 200 - - - synopsis: Create an index named `games` with default settings. - path: /{index} - method: PUT - parameters: - index: games - - - synopsis: Add documents to the `books` index. - path: /{index}/_doc/{id} - method: POST - parameters: - index: books - id: '1' - request: - payload: - name: Book 1 - age: 10 - response: - status: 201 - - - synopsis: Add more documents to the `books` index. - path: /{index}/_doc/{id} - method: POST - parameters: - index: books - id: '2' - request: - payload: - name: Book 2 - age: 20 - response: - status: 201 - - - synopsis: Add another document to the `books` index. - path: /{index}/_doc/{id} - method: POST - parameters: - index: books - id: '3' - request: - payload: - name: Book 3 - age: 30 - response: - status: 201 - - - synopsis: Perform a `_mget` request to retrieve documents by IDs. - path: /{index}/_mget - method: POST - parameters: - index: books - request: - payload: - ids: ['1', '2', '3'] - response: - status: 200 - payload: - docs: - - _index: books - _id: '1' - _source: - name: Book 1 - age: 10 - - _index: books - _id: '2' - _source: - name: Book 2 - age: 20 - - _index: books - _id: '3' - _source: - name: Book 3 - age: 30 - - synopsis: Perform a `_msearch` request to execute multiple search queries in a single call. path: /{index}/_msearch method: POST @@ -110,15 +29,8 @@ chapters: content_type: application/x-ndjson payload: - {index: books} - - {query: {match: {name: Book 1}}} + - {query: {match: {title: To Kill a Mockingbird}}} - {index: books} - - {query: {match: {name: Book 2}}} - response: - status: 200 - - synopsis: Delete the `books` and `games` indices. - path: /{index} - method: DELETE - parameters: - index: books,games + - {query: {match: {title: The Cruise}}} response: status: 200 \ No newline at end of file diff --git a/tests/default/indices/refresh.yaml b/tests/default/indices/refresh.yaml index 9fb1e7598..55b171e23 100644 --- a/tests/default/indices/refresh.yaml +++ b/tests/default/indices/refresh.yaml @@ -27,30 +27,6 @@ chapters: - synopsis: Refresh an index (POST). path: /{index}/_refresh method: POST - parameters: - index: movies - ignore_unavailable: true - allow_no_indices: false - expand_wildcards: all - response: - status: 200 - payload: - _shards: - failed: 0 - - synopsis: Adding one more document. - path: /{index}/_doc - method: POST - parameters: - index: movies - request: - payload: - title: Margin call - year: 2011 - response: - status: 201 - - synopsis: Refresh an index. - path: /{index}/_refresh - method: GET parameters: index: movies ignore_unavailable: true diff --git a/tests/default/indices/validate_query.yaml b/tests/default/indices/validate_query.yaml new file mode 100644 index 000000000..a75ca2e97 --- /dev/null +++ b/tests/default/indices/validate_query.yaml @@ -0,0 +1,49 @@ +$schema: ../../../json_schemas/test_story.schema.yaml + +description: Test validating queries for a specific index using both GET and POST methods. +epilogues: + - path: /movies + method: DELETE + status: [200, 404] +prologues: + - path: /_bulk + method: POST + parameters: + refresh: true + request: + content_type: application/x-ndjson + payload: + - {create: {_index: movies, _id: movie1}} + - {director: Bennett Miller, title: The Cruise, year: 1998} + - {create: {_index: movies, _id: movie2}} + - {director: Nicolas Winding Refn, title: Drive, year: 1960} +chapters: + - synopsis: Validate a match query (GET). + path: /{index}/_validate/query + method: GET + parameters: + index: movies + request: + payload: + query: + match: + year: 1998 + response: + status: 200 + payload: + valid: true + + - synopsis: Validate a match query (POST). + path: /{index}/_validate/query + method: POST + parameters: + index: movies + request: + payload: + query: + match: + title: Drive + response: + status: 200 + payload: + valid: true \ No newline at end of file