Skip to content

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

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

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>
$ref: '#/components/schemas/_common.query_dsl___GeoShape'
relation:
$ref: '#/components/schemas/_common___GeoShapeRelation'
required:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @arimu1 , please submit a pull request against https://github.com/OpenSearch-project/openSearch-api-specification

@arimu1

arimu1 commented Aug 11, 2026

Copy link
Copy Markdown
Author

@reta Thanks for the review direction — understood that indexed_shape / required-shape must be fixed in the OpenAPI source of truth first (OpenSearch-project/opensearch-api-specification), not as a hand-edit of generated client sources.

I'll open a PR against the API specification for the geo/xy shape oneOf (inline shape or indexed_shape) and follow the client regen path after that lands. Leaving this PR open as a temporary client-side illustration until the spec PR is up; happy to close #2088 if you prefer that sequencing.

@reta

reta commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

happy to close #2088 if you prefer that sequencing.

Thanks @arimu1 , you could close the pull request, the change in schema will be picked up

@arimu1

arimu1 commented Aug 11, 2026

Copy link
Copy Markdown
Author

Closing as requested — the schema fix needs to land in opensearch-api-specification first, then the client can pick it up via regeneration.

Happy to open a follow-up once the OpenAPI change is in.

@arimu1 arimu1 closed this Aug 11, 2026
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

2 participants