You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The GeoShapeQueryField schema marks shape as required, but the OpenSearch geo_shape query supports a pre-indexed shape form that uses indexed_shape and no sibling shape. Because this spec is the source of truth for generated clients, the requiredness propagates downstream and makes it impossible to build a pre-indexed shape query with the generated classes.
Current schema (spec/schemas/_common.query_dsl.yaml, main):
A pre-indexed shape query is valid against OpenSearch. This is the pre-indexed example from the docs (index pre-indexed-shapes, document id search_triangle, path boundaries):
indexed_shape was added to the schema later, but required: - shape was not revisited. That produced the current mismatch: indexed_shape is optional while shape stays mandatory.
either shape or indexed_shape can be used, but not both;
the fix should be made in the API spec first, otherwise the change in the client repo is overwritten by regeneration.
Generated client repro (opensearch-java):
newQuery.Builder()
.geoShape(newGeoShapeQuery.Builder()
.field("some")
.shape(shape -> shape.indexedShape(i -> i.index("some").id("id").path("path")))
.build())
.build();
// GeoShapeQueryField requires `shape`, so an indexed_shape-only query can't be built.
What is the expected behavior?
The schema should allow a GeoShapeQueryField that provides indexed_shape without shape, matching the documented pre-indexed shape query.
Open questions for maintainers (how to model the contract)
I'd like to align on the intended schema shape before opening a PR:
Is the contract "exactly one of shape / indexed_shape" (mutually exclusive), or "at least one of them"? The docs read as one-or-the-other.
How should this be expressed in the spec: simply dropping required: - shape, or using oneOf / minProperties / another construct that the codegen and existing spec conventions support?
XyShapeQueryField has the same issue. It carries an identical required: - shape alongside an optional indexed_shape, so it likely needs the same treatment (it was introduced as XyShapeField in Update spec and add tests for xy, geo shape, and geo bounding box query #531 and later renamed, same as the geo variant).
What is the bug?
The
GeoShapeQueryFieldschema marksshapeas required, but the OpenSearch geo_shape query supports a pre-indexed shape form that usesindexed_shapeand no siblingshape. Because this spec is the source of truth for generated clients, the requiredness propagates downstream and makes it impossible to build a pre-indexed shape query with the generated classes.Current schema (
spec/schemas/_common.query_dsl.yaml, main):Per the docs,
shapeandindexed_shapeare alternatives (one or the other, not both):https://docs.opensearch.org/latest/query-dsl/geo-and-xy/geoshape/#using-a-pre-indexed-shape-definition
How can one reproduce the bug?
A pre-indexed shape query is valid against OpenSearch. This is the pre-indexed example from the docs (index
pre-indexed-shapes, document idsearch_triangle, pathboundaries):Validating this body against the current schema fails because
shapeis missing, even though the query has no inline shape by design.How did this happen? (timeline)
GeoShapeField) withrequired: - shape. At that time the schema had onlyshapeandrelation, with noindexed_shape, so requiringshapewas consistent.indexed_shapewas added to the schema later, butrequired: - shapewas not revisited. That produced the current mismatch:indexed_shapeis optional whileshapestays mandatory.(Origin PR: #531)
Downstream impact
Reported in the Java client: opensearch-project/opensearch-java#2011
Maintainer confirmation on that issue (xluo-aws):
shapeorindexed_shapecan be used, but not both;Generated client repro (opensearch-java):
What is the expected behavior?
The schema should allow a
GeoShapeQueryFieldthat providesindexed_shapewithoutshape, matching the documented pre-indexed shape query.Open questions for maintainers (how to model the contract)
I'd like to align on the intended schema shape before opening a PR:
shape/indexed_shape" (mutually exclusive), or "at least one of them"? The docs read as one-or-the-other.required: - shape, or usingoneOf/minProperties/ another construct that the codegen and existing spec conventions support?XyShapeQueryFieldhas the same issue. It carries an identicalrequired: - shapealongside an optionalindexed_shape, so it likely needs the same treatment (it was introduced asXyShapeFieldin Update spec and add tests for xy, geo shape, and geo bounding box query #531 and later renamed, same as the geo variant).tests/default/_core/search/query/geo_shape_*.yamlfrom Update spec and add tests for xy, geo shape, and geo bounding box query #531, but none cover theindexed_shapepath.Additional context