Skip to content

Commit

Permalink
Add geodistance query test (#427)
Browse files Browse the repository at this point in the history
* Add geodistance query test

Signed-off-by: Fanit Kolchina <[email protected]>

* Correct linting errors

Signed-off-by: Fanit Kolchina <[email protected]>

* Correct method name

Signed-off-by: Fanit Kolchina <[email protected]>

* Fixed merge conflicts

Signed-off-by: Fanit Kolchina <[email protected]>

---------

Signed-off-by: Fanit Kolchina <[email protected]>
Signed-off-by: Daniel (dB.) Doubrovkine <[email protected]>
Co-authored-by: Daniel (dB.) Doubrovkine <[email protected]>
  • Loading branch information
kolchfa-aws and dblock authored Jul 18, 2024
1 parent b553c4b commit 51cb05a
Show file tree
Hide file tree
Showing 10 changed files with 332 additions and 151 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Added missing metrics options to `/_nodes/stats` ([#422](https://github.com/opensearch-project/opensearch-api-specification/pull/422))
- Added tests against OpenSearch 1.3 ([#424](https://github.com/opensearch-project/opensearch-api-specification/pull/424))
- Added `is_hidden` to `/{index}/_alias/{name}` and `/{index}/_aliases/{name}` ([#429](https://github.com/opensearch-project/opensearch-api-specification/pull/429))
- Added `ignore_unmapped` to `GeoDistanceQuery` ([#427](https://github.com/opensearch-project/opensearch-api-specification/pull/427))

### Changed

Expand Down
9 changes: 9 additions & 0 deletions spec/schemas/_common.query_dsl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -625,8 +625,17 @@ components:
$ref: '_common.yaml#/components/schemas/GeoDistanceType'
validation_method:
$ref: '#/components/schemas/GeoValidationMethod'
ignore_unmapped:
description: |-
Set to `true` to ignore an unmapped field and not match any documents for this query.
Set to `false` to throw an exception if the field is not mapped.
type: boolean
default: false
field:
type: object
required:
- distance
- field
GeoPolygonQuery:
allOf:
- $ref: '#/components/schemas/QueryBase'
Expand Down
151 changes: 0 additions & 151 deletions tests/_core/search.yaml

This file was deleted.

28 changes: 28 additions & 0 deletions tests/_core/search/cancel_after_time_interval.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
$schema: ../../../json_schemas/test_story.schema.yaml

description: Test search endpoint with cancel_after_time_interval.
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 with cancel_after_time_interval.
path: /{index}/_search
parameters:
index: movies
cancel_after_time_interval: 10s
method: POST
response:
status: 200

60 changes: 60 additions & 0 deletions tests/_core/search/geo_distance.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
$schema: ../../../json_schemas/test_story.schema.yaml

description: Test search endpoint with geo_distance query.
prologues:
- path: /map
method: PUT
request_body:
payload:
mappings:
properties:
field:
type: geo_point
- path: /map/_doc/1
method: POST
parameters:
refresh: true
request_body:
payload:
field:
lat: 74
lon: 40.71
status: [201]
epilogues:
- path: /map
method: DELETE
status: [200, 404]
chapters:
- synopsis: Search for documents whose point objects are within the specified distance from the specified point.
path: /{index}/_search
parameters:
index: map
method: GET
request_body:
payload:
query:
geo_distance:
distance: 50mi
distance_type: arc
validation_method: strict
ignore_unmapped: true
field:
lat: 73.5
lon: 40.5
response:
status: 200
payload:
timed_out: false
hits:
total:
value: 1
relation: eq
max_score: 1
hits:
- _index: map
_score: 1
_source:
field:
lat: 74
lon: 40.71

56 changes: 56 additions & 0 deletions tests/_core/search/match.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
$schema: ../../../json_schemas/test_story.schema.yaml

description: Test search endpoint with match query.
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 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
response:
status: 200
payload:
timed_out: false
hits:
total:
value: 1
relation: eq
hits:
- _index: movies
_source:
director: Bennett Miller
title: Moneyball
year: 2011
45 changes: 45 additions & 0 deletions tests/_core/search/multi_match.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
$schema: ../../../json_schemas/test_story.schema.yaml

description: Test search endpoint with multi_match query.
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 with multi_match query.
path: /{index}/_search
parameters:
index: movies
method: POST
request_body:
payload:
size: 1
query:
multi_match:
query: miller
fields: [director, title^2]
response:
status: 200
payload:
timed_out: false
hits:
total:
value: 1
relation: eq
hits:
- _index: movies
_source:
director: Bennett Miller
title: Moneyball
year: 2011
28 changes: 28 additions & 0 deletions tests/_core/search/phase_took.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
$schema: ../../../json_schemas/test_story.schema.yaml

description: Test search endpoint with phase_took.
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 with phase_took.
version: '>= 2.12'
path: /{index}/_search
parameters:
index: movies
phase_took: true
method: POST
response:
status: 200
Loading

0 comments on commit 51cb05a

Please sign in to comment.