Skip to content

Commit

Permalink
Added direction sort without order.
Browse files Browse the repository at this point in the history
Signed-off-by: dblock <[email protected]>
  • Loading branch information
dblock committed Nov 7, 2024
1 parent d170916 commit 1c3c0e8
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 35 deletions.
6 changes: 6 additions & 0 deletions spec/schemas/_common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -558,10 +558,16 @@ components:
oneOf:
- title: field
$ref: '#/components/schemas/Field'
- title: field_with_direction
$ref: '#/components/schemas/FieldWithDirection'
- title: field_with_order
$ref: '#/components/schemas/FieldWithOrder'
- title: options
$ref: '#/components/schemas/SortOptions'
FieldWithDirection:
type: object
additionalProperties:
$ref: '#/components/schemas/SortOrder'
FieldWithOrder:
type: object
additionalProperties:
Expand Down
39 changes: 39 additions & 0 deletions tests/default/_core/search/search_after.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
$schema: ../../../../json_schemas/test_story.schema.yaml

description: Test search endpoint with search_after.
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}}
- {title: The Cruise, year: 1998}
- {create: {_index: movies}}
- {title: Drive, year: 1960}
chapters:
- synopsis: Search with search_after.
path: /{index}/_search
parameters:
index: movies
request:
payload:
sort:
- year: asc
search_after:
- 1960
method: POST
response:
status: 200
payload:
hits:
hits:
- _source:
title: The Cruise
year: 1998
79 changes: 44 additions & 35 deletions tests/default/_core/search/sort_by_field.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ $schema: ../../../../json_schemas/test_story.schema.yaml
description: Test different ways to sort by field.

epilogues:
- path: /sorted_movies
- path: /movies
method: DELETE
status: [200]

prologues:
- path: /sorted_movies
- path: /movies
method: PUT
request:
payload:
Expand All @@ -18,40 +18,25 @@ prologues:
type: keyword
year:
type: integer

- path: /sorted_movies/_doc
method: POST
parameters:
refresh: true
request:
payload:
title: The Lion King
year: 1994
status: [201]
- path: /sorted_movies/_doc
method: POST
parameters:
refresh: true
request:
payload:
title: The Lion King
year: 2019
status: [201]
- path: /sorted_movies/_doc
- path: /_bulk
method: POST
parameters:
refresh: true
request:
content_type: application/x-ndjson
payload:
title: Frozen
year: 2013
status: [201]
- {create: {_index: movies}}
- {title: The Lion King, year: 1994}
- {create: {_index: movies}}
- {title: The Lion King, year: 2019}
- {create: {_index: movies}}
- {title: Frozen, year: 2013}

chapters:
- synopsis: QueryString Sort by year.
- synopsis: Sort by year.
path: /{index}/_search
parameters:
index: sorted_movies
index: movies
sort: year
method: GET
response:
Expand All @@ -69,10 +54,10 @@ chapters:
title: The Lion King
year: 2019

- synopsis: QueryString Sort by title:desc.
- synopsis: Sort by title:desc.
path: /{index}/_search
parameters:
index: sorted_movies
index: movies
sort: title:desc
method: GET
response:
Expand All @@ -90,10 +75,10 @@ chapters:
title: Frozen
year: 2013

- synopsis: QueryString Sort by title:desc,year:desc.
- synopsis: Sort by title:desc,year:desc.
path: /{index}/_search
parameters:
index: sorted_movies
index: movies
sort: title:desc,year:desc
method: GET
response:
Expand All @@ -111,10 +96,10 @@ chapters:
title: Frozen
year: 2013

- synopsis: Body Sort by [title, year].
- synopsis: Sort by [title, year].
path: /{index}/_search
parameters:
index: sorted_movies
index: movies
method: GET
request:
payload:
Expand All @@ -136,10 +121,10 @@ chapters:
title: The Lion King
year: 2019

- synopsis: Body Sort by year:asc,title:desc.
- synopsis: Sort by year:asc,title:desc.
path: /{index}/_search
parameters:
index: sorted_movies
index: movies
method: GET
request:
payload:
Expand All @@ -161,3 +146,27 @@ chapters:
title: The Lion King
year: 1994

- synopsis: Sort with direction by year:asc,title:desc.
path: /{index}/_search
parameters:
index: movies
method: GET
request:
payload:
sort:
- title: asc
- year: desc
response:
status: 200
payload:
hits:
hits:
- _source:
title: Frozen
year: 2013
- _source:
title: The Lion King
year: 2019
- _source:
title: The Lion King
year: 1994

0 comments on commit 1c3c0e8

Please sign in to comment.