From 9f51d8ede70610f69ede02240a5cacc70dcb1dca Mon Sep 17 00:00:00 2001 From: "uri.nudelman" Date: Wed, 14 Aug 2024 13:18:51 -0400 Subject: [PATCH 1/6] Fixes NeuralQuery Schema Signed-off-by: uri.nudelman --- spec/schemas/_common.query_dsl.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/schemas/_common.query_dsl.yaml b/spec/schemas/_common.query_dsl.yaml index a4bb57b06..33d308535 100644 --- a/spec/schemas/_common.query_dsl.yaml +++ b/spec/schemas/_common.query_dsl.yaml @@ -1237,7 +1237,6 @@ components: type: string query_image: type: string - format: binary model_id: type: string k: @@ -1248,8 +1247,9 @@ components: type: number filter: $ref: '#/components/schemas/QueryContainer' - required: - - model_id + anyOf: + - required: query_text + - required: query_image ParentIdQuery: allOf: - $ref: '#/components/schemas/QueryBase' From ec130568f8e89f73ae45272a30d5aab320b9014d Mon Sep 17 00:00:00 2001 From: "uri.nudelman" Date: Wed, 14 Aug 2024 16:37:24 -0400 Subject: [PATCH 2/6] Remove unsupported validation Signed-off-by: uri.nudelman --- spec/schemas/_common.query_dsl.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/spec/schemas/_common.query_dsl.yaml b/spec/schemas/_common.query_dsl.yaml index 33d308535..93205cbb2 100644 --- a/spec/schemas/_common.query_dsl.yaml +++ b/spec/schemas/_common.query_dsl.yaml @@ -1247,9 +1247,6 @@ components: type: number filter: $ref: '#/components/schemas/QueryContainer' - anyOf: - - required: query_text - - required: query_image ParentIdQuery: allOf: - $ref: '#/components/schemas/QueryBase' From a3921b755d53c76a5ba259dc1074bbb15895f0b0 Mon Sep 17 00:00:00 2001 From: "uri.nudelman" Date: Wed, 14 Aug 2024 18:32:26 -0400 Subject: [PATCH 3/6] Adds encoding base64 Signed-off-by: uri.nudelman --- spec/schemas/_common.query_dsl.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/schemas/_common.query_dsl.yaml b/spec/schemas/_common.query_dsl.yaml index 93205cbb2..28991fc6b 100644 --- a/spec/schemas/_common.query_dsl.yaml +++ b/spec/schemas/_common.query_dsl.yaml @@ -1237,6 +1237,7 @@ components: type: string query_image: type: string + contentEncoding: base64 model_id: type: string k: From 2477d154644bfec767370fe04a32f1a375e7bbaf Mon Sep 17 00:00:00 2001 From: "uri.nudelman" Date: Wed, 14 Aug 2024 19:50:13 -0400 Subject: [PATCH 4/6] Add CHANGELOG Signed-off-by: uri.nudelman --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b8fd3cefc..0100e2a0b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -122,6 +122,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Fixed accuracy of the index stats schemas ([#491](https://github.com/opensearch-project/opensearch-api-specification/pull/491)) - Fixed security spec to add support for 400 and 403s ([#439](https://github.com/opensearch-project/opensearch-api-specification/pull/439)) - Fixed required parameters in `NodeInfo` and `NodeOperatingSystemInfo` ([#483](https://github.com/opensearch-project/opensearch-api-specification/pull/483)) +- Fixed query DSL `neural` field `query_image` set `contentEncoding` and `model_id` as optional ([#512](https://github.com/opensearch-project/opensearch-api-specification/pull/512)) ### Security From 24b1787f6fac0cec3373a9969d338a1647c63dae Mon Sep 17 00:00:00 2001 From: "uri.nudelman" Date: Fri, 16 Aug 2024 17:59:27 -0400 Subject: [PATCH 5/6] Adding Test Case Signed-off-by: uri.nudelman --- .../ingest/pipeline/neural_search.yaml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tests/default/ingest/pipeline/neural_search.yaml b/tests/default/ingest/pipeline/neural_search.yaml index 2d8b41ec1..228e0026b 100644 --- a/tests/default/ingest/pipeline/neural_search.yaml +++ b/tests/default/ingest/pipeline/neural_search.yaml @@ -158,7 +158,7 @@ chapters: - {director: Nicolas Winding Refn, title: Drive, year: 1960} response: status: 200 - - synopsis: Search. + - synopsis: Search by Text. path: /{index}/_search method: POST parameters: @@ -185,6 +185,23 @@ chapters: title: Moneyball script: source: _score * 1.7 + - synopsis: Search by Image - Invalid Model. + path: /{index}/_search + method: POST + parameters: + index: movies + request: + payload: + _source: + excludes: [passage_embedding] + query: + neural: + passage_embedding: + query_image: iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAAAIGNIUk0AAHomAACAhAAA+gAAAIDoAAB1MAAA6mAAADqYAAAXcJy6UTwAAAACYktHRAAAqo0jMgAAAAd0SU1FB+gIDhYxKXooT6EAAAEPSURBVCjPfdExS4IBFIXhJ/lWs8GwKZHaWxsKlaAcamxzUvsB7S1KDQ1B0NoYVLZEjS1Sof9C+krNxKVRCWowi6A64z1w73vPYaRATlXHwEDbmVXByJgACTs2NdW8ICEjpWpPz6d9JVQQRVkZUUWhS9Oj5UdCaSRVPHlSkUTag0MBOV0FxN1oamlpuhFHwbNVqupi2NCTderUir51xNSdRSypecW7MXbDgUe8qllmqMjXibbwkwGKhhFj9W058SaQdyw+Hkf0zYEFefsabpUsWATz+hH3MmKYtW3xiwSmZN3992ZJ19rfQWWEjkaNJFx5+BH1pJLQtcTvZc3ISLmw6+UbKJBzrmNoqOPc2rjuDx+YYcUqo2MMAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDI0LTA4LTE0VDIyOjQ5OjI4KzAwOjAwtj8PBwAAACV0RVh0ZGF0ZTptb2RpZnkAMjAyNC0wOC0xNFQyMjo0OToyOCswMDowMMdit7sAAAAodEVYdGRhdGU6dGltZXN0YW1wADIwMjQtMDgtMTRUMjI6NDk6NDErMDA6MDDDgNowAAAAAElFTkSuQmCC + model_id: UNKNOWN # This + k: 100 + response: + status: 404 - synopsis: Undeploy a model. path: /_plugins/_ml/models/{model_id}/_undeploy method: POST From 1e38f88a7e884f56dd99300bfbd334738aa6152d Mon Sep 17 00:00:00 2001 From: "uri.nudelman" Date: Sun, 18 Aug 2024 18:51:10 -0400 Subject: [PATCH 6/6] Adding Tests and Error Responses to Schema Signed-off-by: uri.nudelman --- spec/namespaces/_core.yaml | 28 ++++++++++++++++++- spec/schemas/query._common.yaml | 8 +++--- .../ingest/pipeline/neural_search.yaml | 4 +-- 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/spec/namespaces/_core.yaml b/spec/namespaces/_core.yaml index bc90411bb..dc0089b29 100644 --- a/spec/namespaces/_core.yaml +++ b/spec/namespaces/_core.yaml @@ -696,6 +696,10 @@ paths: responses: '200': $ref: '#/components/responses/search@200' + '400': + $ref: '#/components/responses/search@400' + '404': + $ref: '#/components/responses/search@404' post: operationId: search.1 x-operation-group: search @@ -755,6 +759,10 @@ paths: responses: '200': $ref: '#/components/responses/search@200' + '400': + $ref: '#/components/responses/search@400' + '404': + $ref: '#/components/responses/search@404' /_search/point_in_time: delete: operationId: delete_pit.0 @@ -1724,6 +1732,10 @@ paths: responses: '200': $ref: '#/components/responses/search@200' + '400': + $ref: '#/components/responses/search@400' + '404': + $ref: '#/components/responses/search@404' post: operationId: search.3 x-operation-group: search @@ -1784,6 +1796,10 @@ paths: responses: '200': $ref: '#/components/responses/search@200' + '400': + $ref: '#/components/responses/search@400' + '404': + $ref: '#/components/responses/search@404' /{index}/_search/point_in_time: post: operationId: create_pit.0 @@ -3044,6 +3060,16 @@ components: application/json: schema: $ref: '../schemas/_core.search.yaml#/components/schemas/ResponseBody' + search@400: + content: + application/json: + schema: + $ref: '../schemas/query._common.yaml#/components/schemas/ErrorResponse' + search@404: + content: + application/json: + schema: + $ref: '../schemas/query._common.yaml#/components/schemas/ErrorResponse' search_shards@200: content: application/json: @@ -6259,4 +6285,4 @@ components: description: The throttle for this request in sub-requests per second. schema: type: number - style: form + style: form \ No newline at end of file diff --git a/spec/schemas/query._common.yaml b/spec/schemas/query._common.yaml index 080c3afa3..40277b8b0 100644 --- a/spec/schemas/query._common.yaml +++ b/spec/schemas/query._common.yaml @@ -79,10 +79,10 @@ components: $ref: '#/components/schemas/RootCause' type: type: string - example: status_exception + # example: status_exception reason: type: string - example: DataSource not found + # example: DataSource not found required: - reason - root_cause @@ -93,10 +93,10 @@ components: properties: type: type: string - example: status_exception + # example: status_exception reason: type: string - example: DataSource not found + # example: DataSource not found required: - reason - type diff --git a/tests/default/ingest/pipeline/neural_search.yaml b/tests/default/ingest/pipeline/neural_search.yaml index 228e0026b..97beeaabc 100644 --- a/tests/default/ingest/pipeline/neural_search.yaml +++ b/tests/default/ingest/pipeline/neural_search.yaml @@ -197,8 +197,8 @@ chapters: query: neural: passage_embedding: - query_image: iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAAAIGNIUk0AAHomAACAhAAA+gAAAIDoAAB1MAAA6mAAADqYAAAXcJy6UTwAAAACYktHRAAAqo0jMgAAAAd0SU1FB+gIDhYxKXooT6EAAAEPSURBVCjPfdExS4IBFIXhJ/lWs8GwKZHaWxsKlaAcamxzUvsB7S1KDQ1B0NoYVLZEjS1Sof9C+krNxKVRCWowi6A64z1w73vPYaRATlXHwEDbmVXByJgACTs2NdW8ICEjpWpPz6d9JVQQRVkZUUWhS9Oj5UdCaSRVPHlSkUTag0MBOV0FxN1oamlpuhFHwbNVqupi2NCTderUir51xNSdRSypecW7MXbDgUe8qllmqMjXibbwkwGKhhFj9W058SaQdyw+Hkf0zYEFefsabpUsWATz+hH3MmKYtW3xiwSmZN3992ZJ19rfQWWEjkaNJFx5+BH1pJLQtcTvZc3ISLmw6+UbKJBzrmNoqOPc2rjuDx+YYcUqo2MMAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDI0LTA4LTE0VDIyOjQ5OjI4KzAwOjAwtj8PBwAAACV0RVh0ZGF0ZTptb2RpZnkAMjAyNC0wOC0xNFQyMjo0OToyOCswMDowMMdit7sAAAAodEVYdGRhdGU6dGltZXN0YW1wADIwMjQtMDgtMTRUMjI6NDk6NDErMDA6MDDDgNowAAAAAElFTkSuQmCC - model_id: UNKNOWN # This + query_image: iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII= + model_id: invalid # This makes the test fail with a 404 but will still validate the query_image. k: 100 response: status: 404