3
votes

I'm trying to solve a problem where I have a set of documents in MarkLogic and I would like to search for a particular node at a particular point in the hierarchy. I would like to use something like a cts:element-value-query, but it seems like it doesn't have the option to specify a hierarchy level or similar.

The reason I would like to do this is that there are identically namespaced/named nodes elsewhere in the hierarchy which I would like to ignore for the purpose of this particular query.

An example would be something like this:

<rootNode xmlns="myNamespace">
    <someBooleanValue>true</someBooleanValue>
    <someSubNode> 
        <someBooleanValue>false</someBooleanValue>
    </someSubNode>
</rootNode>

where I would want, e.g., rootNodes where someBooleanValue was true as a direct child to the root. I know how to query specifically for the someBooleanValue child of someSubNode, but I'm trying to figure out how to do it specifically for the child of rootNode.

For the purpose of this question, please assume that changing the XML structure/namespaces is not easy. This is specifically for MarkLogic 5.x.

Thanks!

1

1 Answers

2
votes

You could wrap your query in cts:element-query's, but that is like an ancestor-or-self check, not necessarily a parent only check. If you use such general names, that is likely to be insufficient.

Better option is to consider upgrade to ML 6 after all, where they have introduces path indexes, where you are allowed to specify specific paths to elements. Might just be worth it..

HTH!