Skip to content

Commit

Permalink
Fixes NeuralQuery Schema (#512)
Browse files Browse the repository at this point in the history
* Fixes NeuralQuery Schema

Signed-off-by: uri.nudelman <uriel.nudelman@offerup.com>

* Remove unsupported validation

Signed-off-by: uri.nudelman <uriel.nudelman@offerup.com>

* Adds encoding base64

Signed-off-by: uri.nudelman <uriel.nudelman@offerup.com>

* Add CHANGELOG

Signed-off-by: uri.nudelman <uriel.nudelman@offerup.com>

* Adding Test Case

Signed-off-by: uri.nudelman <uriel.nudelman@offerup.com>

* Adding Tests and Error Responses to Schema

Signed-off-by: uri.nudelman <uriel.nudelman@offerup.com>

---------

Signed-off-by: uri.nudelman <uriel.nudelman@offerup.com>
Co-authored-by: uri.nudelman <uriel.nudelman@offerup.com>
  • Loading branch information
urinud and uriofferup authored Aug 19, 2024
1 parent 3b02ba3 commit 52ec375
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,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

Expand Down
28 changes: 27 additions & 1 deletion spec/namespaces/_core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -6259,4 +6285,4 @@ components:
description: The throttle for this request in sub-requests per second.
schema:
type: number
style: form
style: form
4 changes: 1 addition & 3 deletions spec/schemas/_common.query_dsl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1237,7 +1237,7 @@ components:
type: string
query_image:
type: string
format: binary
contentEncoding: base64
model_id:
type: string
k:
Expand All @@ -1248,8 +1248,6 @@ components:
type: number
filter:
$ref: '#/components/schemas/QueryContainer'
required:
- model_id
ParentIdQuery:
allOf:
- $ref: '#/components/schemas/QueryBase'
Expand Down
8 changes: 4 additions & 4 deletions spec/schemas/query._common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
19 changes: 18 additions & 1 deletion tests/default/ingest/pipeline/neural_search.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,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:
Expand All @@ -192,6 +192,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: iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=
model_id: invalid # This makes the test fail with a 404 but will still validate the query_image.
k: 100
response:
status: 404
- synopsis: Undeploy a model.
path: /_plugins/_ml/models/{model_id}/_undeploy
method: POST
Expand Down

0 comments on commit 52ec375

Please sign in to comment.