MLE-32111 Add annotation support to StructuredQueryBuilder (#1648) - #1973
Merged
Conversation
Adds StructuredQueryBuilder.annotation(String...) so callers can attach one or more <annotation> elements to a structured query. The server turns these into cts:annotation elements; they are ignored during evaluation and are useful for documenting or marking parts of a query. Annotation content may be arbitrary XML (including namespaced elements) or plain text. Content is parsed and copied into the query via DOMWriter, with a plain-text fallback for non-XML content. Annotations are serialized after the query elements to satisfy the search schema's ordering requirement. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
rjdew-progress
requested review from
RitaChen609,
jonmille,
ngodugu-marklogic and
rjrudin
as code owners
August 25, 2026 04:09
There was a problem hiding this comment.
Pull request overview
Adds first-class support for emitting <annotation> elements in structured queries via StructuredQueryBuilder.annotation(String...), enabling callers to embed arbitrary XML fragments (including namespaced elements) or plain text as query annotations. This fits into marklogic-client-api as an extension to the Structured Query Builder’s XML serialization capabilities, along with accompanying schema-validating tests.
Changes:
- Added
StructuredQueryBuilder.annotation(String...)and anAnnotationQueryimplementation that parses XML fragments (with plain-text fallback) and serializes annotations as<annotation>elements. - Updated structured query XML serialization to always emit annotation elements after all query elements to satisfy
search.xsdordering. - Added unit tests validating namespaced XML annotations, plain-text annotations, multiple annotations, and enforced ordering.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| marklogic-client-api/src/main/java/com/marklogic/client/query/StructuredQueryBuilder.java | Adds annotation query type, XML-fragment parsing + DOM serialization, and enforces annotation ordering at the top-level query serialization stage. |
| marklogic-client-api/src/test/java/com/marklogic/client/test/StructuredQueryBuilderTest.java | Adds schema-validating tests for annotation serialization (XML + text), multiplicity, and ordering guarantees. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
RitaChen609
approved these changes
Aug 26, 2026
jonmille
approved these changes
Aug 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds StructuredQueryBuilder.annotation(String...) so callers can attach one or more elements to a structured query. The server turns these into cts:annotation elements; they are ignored during evaluation and are useful for documenting or marking parts of a query.
Annotation content may be arbitrary XML (including namespaced elements) or plain text. Content is parsed and copied into the query via DOMWriter, with a plain-text fallback for non-XML content. Annotations are serialized after the query elements to satisfy the search schema's ordering requirement.