Skip to content

Commit

Permalink
Merge branch 'main' into geodistance-fix
Browse files Browse the repository at this point in the history
Signed-off-by: Theo N. Truong <theotr@amazon.com>
  • Loading branch information
nhtruong committed Sep 9, 2024
2 parents fc2a512 + 5cd57c4 commit 0524078
Show file tree
Hide file tree
Showing 9 changed files with 381 additions and 25 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Added request and response schemas for `/_cluster/routing/awareness/{attribute}/weights` ([#524](https://github.com/opensearch-project/opensearch-api-specification/pull/524))
- Added request and response schemas for `/_cluster/decommission/awareness` ([#524](https://github.com/opensearch-project/opensearch-api-specification/pull/524))
- Added `Bytes` component of type number ([#552](https://github.com/opensearch-project/opensearch-api-specification/pull/552))
- Added `xy_shape` query ([#531](https://github.com/opensearch-project/opensearch-api-specification/pull/531))

### Changed

Expand All @@ -114,6 +115,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
### Removed

- Removed the ability to skip an individual spec test ([#358](https://github.com/opensearch-project/opensearch-api-specification/pull/358))
- Removed `shape` query ([#531](https://github.com/opensearch-project/opensearch-api-specification/pull/531))

### Fixed

Expand Down Expand Up @@ -143,9 +145,10 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- 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))
- Fixed `knn` query specification ([#538](https://github.com/opensearch-project/opensearch-api-specification/pull/538))
- Fixed content-type for `/hot_threads` ([#543](https://github.com/opensearch-project/opensearch-api-specification/pull/543))
- Fixed `geo_distance` query spec ([#560](https://github.com/opensearch-project/opensearch-api-specification/pull/560))
- Fixed `/_cluster/settings` returning flat results ([#545](https://github.com/opensearch-project/opensearch-api-specification/pull/545))
- Fixed missing fields in `_cat` API ([#551](https://github.com/opensearch-project/opensearch-api-specification/pull/551))
- Fixed `geo_distance` query spec ([#560](https://github.com/opensearch-project/opensearch-api-specification/pull/560))
- Fixed `geo_bounding_box` and `geo_shape` queries ([#531](https://github.com/opensearch-project/opensearch-api-specification/pull/531))

### Security

Expand Down
20 changes: 13 additions & 7 deletions spec/schemas/_common.mapping.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ components:
- $ref: '#/components/schemas/TokenCountProperty'
- $ref: '#/components/schemas/GeoPointProperty'
- $ref: '#/components/schemas/GeoShapeProperty'
- $ref: '#/components/schemas/PointProperty'
- $ref: '#/components/schemas/ShapeProperty'
- $ref: '#/components/schemas/XyPointProperty'
- $ref: '#/components/schemas/XyShapeProperty'
- $ref: '#/components/schemas/ByteNumberProperty'
- $ref: '#/components/schemas/DoubleNumberProperty'
- $ref: '#/components/schemas/FloatNumberProperty'
Expand Down Expand Up @@ -913,6 +913,10 @@ components:
$ref: '#/components/schemas/GeoOrientation'
strategy:
$ref: '#/components/schemas/GeoStrategy'
deprecated: true
distance_error_pct:
type: number
deprecated: true
type:
type: string
enum:
Expand All @@ -929,7 +933,8 @@ components:
enum:
- recursive
- term
PointProperty:
XyPointProperty:
# x-version-added: 2.4
allOf:
- $ref: '#/components/schemas/DocValuesPropertyBase'
- type: object
Expand All @@ -939,14 +944,15 @@ components:
ignore_z_value:
type: boolean
null_value:
type: string
$ref: '_common.yaml#/components/schemas/XyLocation'
type:
type: string
enum:
- point
- xy_point
required:
- type
ShapeProperty:
XyShapeProperty:
# x-version-added: 2.4
allOf:
- $ref: '#/components/schemas/DocValuesPropertyBase'
- type: object
Expand All @@ -962,7 +968,7 @@ components:
type:
type: string
enum:
- shape
- xy_shape
required:
- type
ByteNumberProperty:
Expand Down
74 changes: 57 additions & 17 deletions spec/schemas/_common.query_dsl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,6 @@ components:
$ref: '#/components/schemas/ScriptQuery'
script_score:
$ref: '#/components/schemas/ScriptScoreQuery'
shape:
$ref: '#/components/schemas/ShapeQuery'
simple_query_string:
$ref: '#/components/schemas/SimpleQueryStringQuery'
span_containing:
Expand Down Expand Up @@ -209,6 +207,8 @@ components:
$ref: '#/components/schemas/TextExpansionQuery'
minProperties: 1
maxProperties: 1
type:
$ref: '#/components/schemas/TypeQuery'
weighted_tokens:
description: Supports returning text_expansion query results by sending in precomputed tokens with the query.
type: object
Expand All @@ -225,8 +225,8 @@ components:
maxProperties: 1
wrapper:
$ref: '#/components/schemas/WrapperQuery'
type:
$ref: '#/components/schemas/TypeQuery'
xy_shape:
$ref: '#/components/schemas/XyShapeQuery'
minProperties: 1
maxProperties: 1
BoolQuery:
Expand Down Expand Up @@ -629,6 +629,9 @@ components:
$ref: '#/components/schemas/GeoValidationMethod'
ignore_unmapped:
$ref: '#/components/schemas/IgnoreUnmapped'
additionalProperties:
$ref: '_common.yaml#/components/schemas/GeoBounds'
minProperties: 1
GeoExecution:
type: string
enum:
Expand Down Expand Up @@ -667,13 +670,32 @@ components:
$ref: '#/components/schemas/GeoValidationMethod'
ignore_unmapped:
$ref: '#/components/schemas/IgnoreUnmapped'
GeoShape:
type: object
properties:
type:
type: string
coordinates:
type: array
GeoShapeField:
type: object
properties:
shape:
$ref: '#/components/schemas/GeoShape'
relation:
$ref: '_common.yaml#/components/schemas/GeoShapeRelation'
required:
- shape
GeoShapeQuery:
allOf:
- $ref: '#/components/schemas/QueryBase'
- type: object
properties:
ignore_unmapped:
$ref: '#/components/schemas/IgnoreUnmapped'
additionalProperties:
$ref: '#/components/schemas/GeoShapeField'
minProperties: 1
HasChildQuery:
allOf:
- $ref: '#/components/schemas/QueryBase'
Expand Down Expand Up @@ -1626,13 +1648,6 @@ components:
required:
- query
- script
ShapeQuery:
allOf:
- $ref: '#/components/schemas/QueryBase'
- type: object
properties:
ignore_unmapped:
$ref: '#/components/schemas/IgnoreUnmapped'
SimpleQueryStringQuery:
allOf:
- $ref: '#/components/schemas/QueryBase'
Expand Down Expand Up @@ -1918,6 +1933,15 @@ components:
only_score_pruned_tokens:
description: Whether to only score pruned tokens, vs only scoring kept tokens.
type: boolean
TypeQuery:
allOf:
- $ref: '#/components/schemas/QueryBase'
- type: object
properties:
value:
type: string
required:
- value
WeightedTokensQuery:
allOf:
- $ref: '#/components/schemas/QueryBase'
Expand Down Expand Up @@ -1960,12 +1984,28 @@ components:
type: string
required:
- query
TypeQuery:
XyShape:
type: object
properties:
type:
type: string
coordinates:
type: array
XyShapeField:
type: object
properties:
shape:
$ref: '#/components/schemas/XyShape'
relation:
$ref: '_common.yaml#/components/schemas/GeoShapeRelation'
required:
- shape
XyShapeQuery:
x-version-added: 2.4
allOf:
- $ref: '#/components/schemas/QueryBase'
- type: object
properties:
value:
type: string
required:
- value
additionalProperties:
$ref: '#/components/schemas/XyShapeField'
minProperties: 1
maxProperties: 1
26 changes: 26 additions & 0 deletions spec/schemas/_common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,32 @@ components:
type: string
required:
- wkt
XyLocation:
x-version-added: 2.4
description: |-
A two-dimensional Cartesian point specified by x and y coordinates. It can be represented in various ways:
- as a `{x, y}` object
- as a `[x, y]` array
- as a string in `"x, y"` or WKT point formats.
oneOf:
- $ref: '#/components/schemas/XyCartesianCoordinates'
- type: array
items:
type: number
- type: string
XyCartesianCoordinates:
x-version-added: '2.4'
type: object
properties:
x:
description: The x coordinate.
type: number
y:
description: The y coordinate.
type: number
required:
- x
- y
EpochTimeUnitMillis:
allOf:
- $ref: '#/components/schemas/UnitMillis'
Expand Down
60 changes: 60 additions & 0 deletions tests/default/_core/search/query/geo_bounding_box.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_bounding_box query.
prologues:
- path: /point_index
method: PUT
request:
payload:
mappings:
properties:
field:
type: geo_point
- path: /point_index/_doc/1
method: POST
parameters:
refresh: true
request:
payload:
field:
lat: 74
lon: 40
status: [201]
epilogues:
- path: /point_index
method: DELETE
status: [200, 404]
chapters:
- synopsis: Search point_index for documents whose point objects are within the specified bounding box.
path: /{index}/_search
parameters:
index: point_index
method: GET
request:
payload:
query:
geo_bounding_box:
field:
top: 75
left: 28
bottom: 73
right: 41
validation_method: strict
type: memory
ignore_unmapped: false
response:
status: 200
payload:
timed_out: false
hits:
total:
value: 1
relation: eq
max_score: 1
hits:
- _index: point_index
_score: 1
_source:
field:
lat: 74
lon: 40
52 changes: 52 additions & 0 deletions tests/default/_core/search/query/geo_shape_point.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
$schema: ../../../../../json_schemas/test_story.schema.yaml

description: Test search endpoint with geo_shape query.
prologues:
- path: /cinemas
method: PUT
request:
payload:
mappings:
properties:
location:
type: geo_point
- path: /cinemas/_doc/1
method: POST
parameters:
refresh: true
request:
payload:
location: [0.5, 3]
status: [201]
epilogues:
- path: /cinemas
method: DELETE
status: [200, 404]
chapters:
- synopsis: Search cinemas for documents whose point objects are within the specified envelope.
path: /{index}/_search
parameters:
index: cinemas
method: GET
request:
payload:
query:
geo_shape:
location:
shape:
type: envelope
coordinates: [[0, 6], [1, 2]]
response:
status: 200
payload:
timed_out: false
hits:
total:
value: 1
relation: eq
max_score: 0
hits:
- _index: cinemas
_score: 0
_source:
location: [0.5, 3]
Loading

0 comments on commit 0524078

Please sign in to comment.