Skip to content

Add agentic query support to the Java client - #1893

Closed
ocuenca-coursera wants to merge 2 commits into
opensearch-project:mainfrom
ocuenca-coursera:feature/add-agentic-query
Closed

Add agentic query support to the Java client#1893
ocuenca-coursera wants to merge 2 commits into
opensearch-project:mainfrom
ocuenca-coursera:feature/add-agentic-query

Conversation

@ocuenca-coursera

@ocuenca-coursera ocuenca-coursera commented Feb 21, 2026

Copy link
Copy Markdown

Summary

  • Adds AgenticQuery as a new variant of the Query tagged union, supporting the agentic query type introduced in OpenSearch 3.2+
  • Enables natural language questions to be translated into DSL queries via a preconfigured agent and search pipeline
  • Follows the same patterns as HybridQuery

Resolves #1892

Test plan

  • ./gradlew :java-client:compileJava — compiles without errors
  • ./gradlew :java-client:test --tests "*AgenticQueryTest*" — new test passes
  • ./gradlew :java-client:test — full test suite passes with no regressions

Adds AgenticQuery as a new variant of the Query tagged union, enabling
natural language questions to be translated into DSL queries via a
preconfigured agent and search pipeline (OpenSearch 3.2+).

Resolves opensearch-project#1892

Signed-off-by: Octavio Cuenca <ocuenca@coursera.org>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
*/

//----------------------------------------------------
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.

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.

Thank you @ocuenca-coursera , I am wondering how this code was generated?

@ocuenca-coursera ocuenca-coursera Feb 21, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The class was created by claude code agent and not for the codegen tool, first time didn't noticed about the codegen tool, I just found out this project uses a 3-stage pipeline in java-codegen/:

opensearch-openapi.yaml
       │
       ▼
 OpenApiSpecification  ──rewriters──►  SpecTransformer
       │                                      │
       │                               model/ObjectShape
       │                               model/TaggedUnionShape
       │                               model/EnumShape, etc.
       ▼
  TemplateRenderer (Mustache templates)
       │
       ▼
  java-client/src/generated/java/...

And that I needed to run ./gradlew :java-codegen:run to generate the new query from opensearch-openapi.yaml. Including those changes in a moment...

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Besides of that command, do you recommend me to run any other?

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.

Oh I see, so we do regenerate models from latest specs automatically, every week (see please #1890). Once the agentic query is in specification (https://github.com/opensearch-project/opensearch-api-specification), it will be available.

Adds the `_common.query_dsl___AgenticQuery` schema to the local
opensearch-openapi.yaml spec and registers the `agentic` variant in
`_common.query_dsl___QueryContainer`, so the generated Java classes
(AgenticQuery, Query, QueryBuilders) are properly derived from the spec
rather than written by hand.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.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.

[FEATURE] Support of agentic search queries for conversational agents

2 participants