Allow indexed_shape-only geo_shape and xy_shape queries - #1161
Allow indexed_shape-only geo_shape and xy_shape queries#1161Tejashribambal19 wants to merge 1 commit into
Conversation
lsh1215
left a comment
There was a problem hiding this comment.
Thanks for picking this up, @Tejashribambal19 — I opened the linked issue #1160. This unblocks the immediate case; I left two inline notes suggesting we model exactly one of shape/indexed_shape (via the existing TermsLookup oneOf pattern) instead of dropping required, since the contract is "one or the other, not both."
One more gap: there's no test coverage for the indexed_shape path yet — the existing geo_shape_* / xy_shape_* stories only exercise inline shape (open question #4 in the issue). I have a branch with the oneOf modeling plus geo_shape_indexed_shape / xy_shape_indexed_shape stories, validated against the merged schema (lint:spec / merge / unit all green). Happy to fold those into this PR or open an alternative — whichever you and the maintainers prefer.
| $ref: '#/components/schemas/GeoShape' | ||
| relation: | ||
| $ref: '_common.yaml#/components/schemas/GeoShapeRelation' | ||
| required: |
There was a problem hiding this comment.
Dropping required unblocks indexed_shape-only, but it also makes both shape+indexed_shape and neither valid. Per the docs and @xluo-aws (opensearch-java#2011), it should be exactly one — already modeled in this same file by TermsLookup:
allOf:
- oneOf:
- type: object
properties:
indexed_shape: { $ref: '#/components/schemas/FieldLookup' }
required: [indexed_shape]
- type: object
properties:
shape: { $ref: '#/components/schemas/GeoShape' }
required: [shape]| $ref: '#/components/schemas/XyShape' | ||
| relation: | ||
| $ref: '_common.yaml#/components/schemas/GeoShapeRelation' | ||
| required: |
There was a problem hiding this comment.
Same here — XyShapeQueryField needs the same exactly-one allOf/oneOf treatment (with XyShape instead of GeoShape).
Summary
Fixes #1160.
The current API specification marks
shapeas required in bothGeoShapeQueryFieldandXyShapeQueryField. However, OpenSearch supports pre-indexed shape queries usingindexed_shapewithout an accompanyingshape, as documented.Because this specification is the source of truth for generated clients, the current requirement prevents clients from constructing valid
indexed_shape-only queries.This PR removes the
shaperequirement from both schemas, allowing both inlineshapequeries and pre-indexedindexed_shapequeries.Changes
required: [shape]fromGeoShapeQueryFieldrequired: [shape]fromXyShapeQueryFieldMotivation
The OpenSearch documentation describes
shapeandindexed_shapeas alternative ways to define a geo/xy shape query. Requiringshapemakes valid pre-indexed shape queries fail schema validation and propagates incorrect constraints to generated clients.This change aligns the API specification with the documented query behavior.
Testing
GeoShapeQueryFieldandXyShapeQueryField.shapequeries.Notes
The current specification tests cover inline shape queries but do not include coverage for the indexed_shape path. This PR focuses on correcting the schema; regression tests for indexed_shape can be added separately if maintainers prefer additional coverage.