Add agentic query support to the Java client#1893
Add agentic query support to the Java client#1893ocuenca-coursera wants to merge 2 commits intoopensearch-project:mainfrom
Conversation
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. |
There was a problem hiding this comment.
Thank you @ocuenca-coursera , I am wondering how this code was generated?
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
Besides of that command, do you recommend me to run any other?
There was a problem hiding this comment.
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>
Summary
AgenticQueryas a new variant of theQuerytagged union, supporting theagenticquery type introduced in OpenSearch 3.2+HybridQueryResolves #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