diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c684781b..981c2c6bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -65,6 +65,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Fixed `/{index}/_open` can return a `task` ([#376](https://github.com/opensearch-project/opensearch-api-specification/pull/376)) - Fixed `_source` in `bulk` responses ([#375](https://github.com/opensearch-project/opensearch-api-specification/pull/375)) - Fixed `/{index}/_dangling` that can return `nodes` and `cluster_name` ([#391](https://github.com/opensearch-project/opensearch-api-specification/pull/391)) +- Fixed query DSL `match` that supports a field name and value ([#405](https://github.com/opensearch-project/opensearch-api-specification/pull/405)) ### Security diff --git a/spec/schemas/_common.query_dsl.yaml b/spec/schemas/_common.query_dsl.yaml index f74bff185..1b5149d15 100644 --- a/spec/schemas/_common.query_dsl.yaml +++ b/spec/schemas/_common.query_dsl.yaml @@ -69,11 +69,16 @@ components: description: |- Returns documents that match a provided text, number, date or boolean value. The provided text is analyzed before matching. - type: object - additionalProperties: - $ref: '#/components/schemas/MatchQuery' - minProperties: 1 - maxProperties: 1 + anyOf: + - type: object + additionalProperties: + $ref: '#/components/schemas/MatchQuery' + minProperties: 1 + maxProperties: 1 + - type: object + additionalProperties: true + minProperties: 1 + maxProperties: 1 match_all: $ref: '#/components/schemas/MatchAllQuery' match_bool_prefix: @@ -516,7 +521,7 @@ components: type: number missing: description: |- - Value used if the document doesn’t have that field. + Value used if the document doesn't have that field. The modifier and factor are still applied to it as though it were read from the document. type: number modifier: @@ -1303,7 +1308,7 @@ components: case_insensitive: description: |- Allows ASCII case insensitive matching of the value with the indexed field values when set to `true`. - Default is `false` which means the case sensitivity of matching depends on the underlying field’s mapping. + Default is `false` which means the case sensitivity of matching depends on the underlying field's mapping. type: boolean required: - value @@ -1520,7 +1525,7 @@ components: case_insensitive: description: |- Allows case insensitive matching of the regular expression value with the indexed field values when set to `true`. - When `false`, case sensitivity of matching depends on the underlying field’s mapping. + When `false`, case sensitivity of matching depends on the underlying field's mapping. type: boolean flags: description: Enables optional operators for the regular expression. @@ -1759,7 +1764,7 @@ components: properties: dist: description: |- - The number of tokens from within the include span that can’t have overlap with the exclude span. + The number of tokens from within the include span that can't have overlap with the exclude span. Equivalent to setting both `pre` and `post`. type: number exclude: @@ -1767,10 +1772,10 @@ components: include: $ref: '#/components/schemas/SpanQuery' post: - description: The number of tokens after the include span that can’t have overlap with the exclude span. + description: The number of tokens after the include span that can't have overlap with the exclude span. type: number pre: - description: The number of tokens before the include span that can’t have overlap with the exclude span. + description: The number of tokens before the include span that can't have overlap with the exclude span. type: number required: - exclude @@ -1818,7 +1823,7 @@ components: case_insensitive: description: |- Allows ASCII case insensitive matching of the value with the indexed field values when set to `true`. - When `false`, the case sensitivity of matching depends on the underlying field’s mapping. + When `false`, the case sensitivity of matching depends on the underlying field's mapping. type: boolean required: - value @@ -1890,7 +1895,7 @@ components: - type: object properties: case_insensitive: - description: Allows case insensitive matching of the pattern with the indexed field values when set to true. Default is false which means the case sensitivity of matching depends on the underlying field’s mapping. + description: Allows case insensitive matching of the pattern with the indexed field values when set to `true`. Default is `false` which means the case sensitivity of matching depends on the underlying field's mapping. type: boolean rewrite: $ref: '_common.yaml#/components/schemas/MultiTermQueryRewrite' diff --git a/tests/_core/reindex.yaml b/tests/_core/reindex.yaml new file mode 100644 index 000000000..958559d25 --- /dev/null +++ b/tests/_core/reindex.yaml @@ -0,0 +1,212 @@ +$schema: ../../json_schemas/test_story.schema.yaml + +description: Test reindex. +epilogues: + - path: /movies + method: DELETE + status: [200, 404] + - path: /films + method: DELETE + status: [200, 404] + - path: /videos + method: DELETE + status: [200, 404] + - path: /_ingest/pipeline/transform-and-count + method: DELETE + status: [200, 404] +chapters: + - synopsis: Create a document. + path: /{index}/_doc + method: POST + parameters: + index: movies + request_body: + payload: + title: Beauty and the Beast + year: 91 + response: + status: 201 + - synopsis: Refresh the index. + path: /{index}/_refresh + method: POST + parameters: + index: movies + - synopsis: Reindex from movies to films. + path: /_reindex + method: POST + request_body: + payload: + source: + index: movies + dest: + index: films + response: + status: 200 + payload: + total: 1 + - synopsis: Reindex a subset of documents (match). + path: /_reindex + method: POST + request_body: + payload: + source: + index: movies + query: + match: + title: Beauty and the Beast + dest: + index: films + response: + status: 200 + payload: + total: 1 + - synopsis: Reindex a subset of documents (no match). + path: /_reindex + method: POST + request_body: + payload: + source: + index: movies + query: + match: + title: Does not Exist + dest: + index: films + response: + status: 200 + payload: + total: 0 + - synopsis: Combine two indexes. + path: /_reindex + method: POST + request_body: + payload: + source: + index: + - movies + - films + dest: + index: videos + response: + status: 200 + payload: + total: 1 + - synopsis: Reindex only unique documents. + path: /_reindex + method: POST + request_body: + payload: + conflicts: proceed + source: + index: movies + dest: + index: videos + op_type: create + response: + status: 200 + payload: + total: 1 + - synopsis: Transform documents during reindexing. + path: /_reindex + method: POST + request_body: + payload: + source: + index: movies + dest: + index: videos + script: + lang: painless + source: ctx._source.year += 1900 + response: + status: 200 + payload: + total: 1 + - synopsis: Create an ingest pipeline. + path: /_ingest/pipeline/{id} + method: PUT + parameters: + id: transform-and-count + request_body: + payload: + description: | + Splits the `title`` field into a `words` list. + Computes the length of the title field and stores it in a new `length` field. + Removes the `year` field. + processors: + - split: + field: title + separator: '\s+' + target_field: words + - script: + lang: painless + source: 'ctx.length = ctx.words.length' + - remove: + field: year + - synopsis: Transform documents using a pipeline. + path: /_reindex + method: POST + request_body: + payload: + source: + index: movies + dest: + index: videos + pipeline: transform-and-count + response: + status: 200 + - synopsis: Refresh the index. + path: /{index}/_refresh + method: POST + parameters: + index: videos + - synopsis: Get all videos. + path: /{index}/_search + method: POST + parameters: + index: videos + request_body: + payload: + query: + match_all: {} + response: + status: 200 + payload: + hits: + hits: + - _index: videos + _source: + words: + - Beauty + - and + - the + - Beast + length: 4 + title: Beauty and the Beast + - synopsis: Update documents in the current index. + path: /{index}/_update_by_query + method: POST + parameters: + index: videos + response: + status: 200 + payload: + updated: 1 + - synopsis: Reindex from movies to films with all options. + path: /_reindex + method: POST + parameters: + max_docs: 1 + slices: 1 + request_body: + payload: + source: + index: movies + size: 1 + dest: + index: films + version_type: internal + response: + status: 200 + payload: + total: 1 \ No newline at end of file diff --git a/tests/_core/search.yaml b/tests/_core/search.yaml index bb574de68..bd3d8d3b2 100644 --- a/tests/_core/search.yaml +++ b/tests/_core/search.yaml @@ -61,6 +61,29 @@ chapters: director: Bennett Miller title: Moneyball year: 2011 + - synopsis: Search with a match query object. + path: /{index}/_search + parameters: + index: movies + method: POST + request_body: + payload: + size: 1 + query: + match: + director: + query: Bennett Miller + - synopsis: Search with a match query field. + path: /{index}/_search + parameters: + index: movies + method: POST + request_body: + payload: + size: 1 + query: + match: + director: Bennett Miller - synopsis: Search with multi_match query. path: /{index}/_search parameters: