java-client-api icon indicating copy to clipboard operation
java-client-api copied to clipboard

Support for cts:annotation in cts:query?

Open ralfhergert opened this issue 11 months ago • 3 comments

CtsQueries allow to be enriched with cts:annotation-elements: https://docs.marklogic.com/guide/search-dev/cts_query#id_28038 Those elements are ignored by MarkLogic when the query is executed. cts:annotations can be used for various purposes (like documentation) and in our case we use it as a marker-element to identify certain parts of the query to be able to modify and manipulate them later after the creation.

Do the QueryBuilders support to add annotation-elements? (I searched, but didn't find it yet.)

ralfhergert avatar Mar 22 '24 10:03 ralfhergert

Correct, there's not support for adding annotation elements. What's your use case for them? Like would you eventually serialize the query to a place where a developer / user would see it?

rjrudin avatar Mar 22 '24 12:03 rjrudin

Hi @rjrudin, we are starting to use alerts in MarkLogic server. The queries used in the alert-rules are composed of two parts: one is given by our customers and the other is given by our rights and roles model. From time to time the rights and roles part is updated and thus we need to update the queries in all alert-rules. Here we only want to modify the half of the query that corresponds to the rights and roles, we absolutely do not want to touch the part of the query given by our customers. - Annotations help us to identify the parts correctly.

ralfhergert avatar Mar 22 '24 15:03 ralfhergert

Hi @ralfhergert - thanks for the feedback. It's not directly supported today via the Java Client, though you would at least have a workaround of:

  1. Serialize your query to XML.
  2. Manually add the annotation elements (annoying, yes, but I don't know of a better way; I would use JDOM2 for this).
  3. Submit your serialized query.

rjrudin avatar Mar 29 '24 17:03 rjrudin