简体   繁体   English

MarkLogic cts:搜索节点层次结构

[英]MarkLogic cts:search node hierarchy

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. 我正在尝试解决我在MarkLogic中有一组文档的问题,并且我想在层次结构中的特定点搜索特定节点。 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. 我想使用类似于cts:element-value-query的东西,但似乎它没有指定层次结构级别或类似的选项。

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, eg, rootNodes where someBooleanValue was true as a direct child to the root. 我想要的地方,例如,rootNodes,其中someBooleanValue为真的直接子根。 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. 我知道如何专门查询someSubNode的someBooleanValue子节点,但我正在试图弄清楚如何专门为rootNode的子节点做这件事。

For the purpose of this question, please assume that changing the XML structure/namespaces is not easy. 出于此问题的目的,请假设更改XML结构/命名空间并不容易。 This is specifically for MarkLogic 5.x. 这是专门针对MarkLogic 5.x.

Thanks! 谢谢!

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. 您可以将查询包装在cts:element-query中,但这类似于祖先或自我检查,不一定只是父检查。 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. 更好的选择是考虑升级到ML 6,它们引入了路径索引,允许您指定元素的特定路径。 Might just be worth it.. 可能值得...

HTH! HTH!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM