Skip to content

Commit

Permalink
Fix _source accepting an array of fields in _search. (#430)
Browse files Browse the repository at this point in the history
Signed-off-by: dblock <[email protected]>
  • Loading branch information
dblock authored Jul 18, 2024
1 parent 0453dbe commit e1cd369
Show file tree
Hide file tree
Showing 3 changed files with 151 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Fixed query DSL `match` that supports a field name and value ([#405](https://github.com/opensearch-project/opensearch-api-specification/pull/405))
- Fixed `/_mapping` with `index` in query ([#385](https://github.com/opensearch-project/opensearch-api-specification/pull/385))
- Fixed duplicate `/_nodes/{node_id}` path ([#416](https://github.com/opensearch-project/opensearch-api-specification/pull/416))
- Fixed `_source` accepting an array of fields in `/_search` ([#430](https://github.com/opensearch-project/opensearch-api-specification/pull/430))

### Security

Expand Down
3 changes: 3 additions & 0 deletions spec/schemas/_core.search.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,9 @@ components:
description: Defines how to fetch a source. Fetching can be disabled entirely, or the source can be filtered.
oneOf:
- type: boolean
- type: array
items:
$ref: '_common.yaml#/components/schemas/Field'
- $ref: '#/components/schemas/SourceFilter'
SourceFilter:
type: object
Expand Down
147 changes: 147 additions & 0 deletions tests/_core/search/_source.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
$schema: ../../../json_schemas/test_story.schema.yaml

description: Test search endpoint (_source).
prologues:
- path: /movies/_doc
method: POST
parameters:
refresh: true
request_body:
payload:
director: Bennett Miller
title: Moneyball
year: 2011
status: [201]
epilogues:
- path: /movies
method: DELETE
status: [200, 404]
chapters:
- synopsis: Search (_source=true).
path: /{index}/_search
parameters:
index: movies
method: POST
request_body:
payload:
_source: true
query:
match_all: {}
response:
status: 200
payload:
timed_out: false
hits:
total:
value: 1
relation: eq
max_score: 1
hits:
- _index: movies
_score: 1
_source:
director: Bennett Miller
title: Moneyball
year: 2011
- synopsis: Search (_source=false).
path: /{index}/_search
parameters:
index: movies
method: POST
request_body:
payload:
_source: false
query:
match_all: {}
response:
status: 200
payload:
timed_out: false
hits:
total:
value: 1
relation: eq
max_score: 1
hits:
- _index: movies
_score: 1
- synopsis: Search (_source=[fields]).
path: /{index}/_search
parameters:
index: movies
method: POST
request_body:
payload:
_source:
- director
- year
query:
match_all: {}
response:
status: 200
payload:
timed_out: false
hits:
total:
value: 1
relation: eq
max_score: 1
hits:
- _index: movies
_score: 1
_source:
director: Bennett Miller
year: 2011
- synopsis: Search (_source=filter).
path: /{index}/_search
parameters:
index: movies
method: POST
request_body:
payload:
_source:
includes: director
excludes: year
query:
match_all: {}
response:
status: 200
payload:
timed_out: false
hits:
total:
value: 1
relation: eq
max_score: 1
hits:
- _index: movies
_score: 1
_source:
director: Bennett Miller
- synopsis: Search (_source=filter with wildcards).
path: /{index}/_search
parameters:
index: movies
method: POST
request_body:
payload:
_source:
includes: '*'
excludes: year
query:
match_all: {}
response:
status: 200
payload:
timed_out: false
hits:
total:
value: 1
relation: eq
max_score: 1
hits:
- _index: movies
_score: 1
_source:
director: Bennett Miller
title: Moneyball

0 comments on commit e1cd369

Please sign in to comment.