Skip to content

fix: allow indexed_shape-only geo/xy shape queries - #2088

Open
arimu1 wants to merge 2 commits into
opensearch-project:mainfrom
arimu1:fix/2011-geoshape-shape-not-required
Open

fix: allow indexed_shape-only geo/xy shape queries#2088
arimu1 wants to merge 2 commits into
opensearch-project:mainfrom
arimu1:fix/2011-geoshape-shape-not-required

Conversation

@arimu1

@arimu1 arimu1 commented Aug 7, 2026

Copy link
Copy Markdown

Description

Fixes #2011.

GeoShapeQueryField (and the sibling XyShapeQueryField) currently mark shape as required. OpenSearch documents that a geo/xy shape query may use either an inline shape or a pre-indexed shape via indexed_shape (not both). Because the generated builder enforces shape, callers cannot construct valid pre-indexed shape queries:

new Query.Builder()
    .geoShape(g -> g
        .field("location")
        .shape(s -> s.indexedShape(i -> i.index("shapes").id("id").path("location")))
    )
    .build();

Changes

  • Remove required: [shape] from _common.query_dsl___GeoShapeQueryField and _common.query_dsl___XyShapeQueryField in java-codegen/opensearch-openapi.yaml
  • Update generated GeoShapeQueryField / XyShapeQueryField so shape is @Nullable (no ApiTypeHelper.requireNonNull, conditional serialization, null-safe equals/hashCode)
  • Add unit coverage for indexed_shape-only construction/serialization
  • CHANGELOG entry under Unreleased 4.x Fixed

Related

Testing

./gradlew :java-client:test \
  --tests org.opensearch.client.opensearch._types.query_dsl.GeoShapeQueryFieldTest \
  --tests org.opensearch.client.opensearch._types.query_dsl.XyShapeQueryFieldTest

Temurin 21 / macOS — 4 tests, 0 failures (toBuilder + indexedShapeOnly for both classes).

Check List

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

The OpenSearch geo_shape / xy_shape APIs allow either an inline shape or
a pre-indexed shape via indexed_shape. Requiring shape in the OpenAPI
schema and generated builders made indexed_shape-only queries impossible.

Remove shape from required in the local OpenAPI copy and update the
generated models so shape is nullable, matching indexed_shape.

Fixes opensearch-project#2011

Signed-off-by: arimu1 <19286898+arimu1@users.noreply.github.com>
Signed-off-by: arimu1 <19286898+arimu1@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] "shape" should not be required in GeoShapeQueryField

1 participant