- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在 MarkLogic 中如何找到元素所在的文档 URI
<sample-ref type="dated">
匹配的值为1742
这里是示例 XML 文档:
<samples>
<sample>
<sample-ref type="dated">1742</sample-ref>
<sample-ref type="undated">1742</sample-ref>
<sample-xref type="sub">
<sample-ref type="dated">TT 1742</sample-ref>
</sample-xref>
<sample-xref type="din">
<sample-ref type="dated">
</sample-ref>
</sample-xref>
<sample-xref type="sup">
<sample-ref type="dated">XX 1742</sample-ref>
</sample-xref>
</sample>
</samples>
我只想查询这个值匹配1742的元素
<sample-ref type="dated">1742</sample-ref>
我尝试过这个查询,但它返回多个 uri:
cts.uris("", null, cts.elementValueQuery(xs.QName("sample-ref"), "1742", "exact"))
如何优化此查询
感谢您的帮助
最佳答案
您正在尝试查询包含 sample-ref
元素(文本内容为“1742”)和值为“dated”的 type
属性的文档。也许您已经发现以下方法不起作用:
cts.elementQuery(xs.QName('sample-ref'), cts.andQuery([
cts.elementAttributeValueQuery(xs.QName('sample-ref'), xs.QName('type'), 'dated'),
cts.elementValueQuery(xs.QName('sample-ref'), '1742')
]))
因为事实证明,除了元素属性查询之外,元素查询中的元素查询仅匹配后代,而不是后代或自身。
David Cassel 在他的博客文章中记录了此问题的一种解决方案:http://blog.davidcassel.net/2012/08/a-trick-with-ctsnear-query/
通过使用距离为 0 的 cts.nearQueries,它会强制 ML 查找子查询与相同元素匹配的位置。
即
cts.uris("", null, cts.nearQuery([
cts.elementAttributeValueQuery(xs.QName('sample-ref'), xs.QName('type'), 'dated'),
cts.elementValueQuery(xs.QName('sample-ref'), '1742')
], 0))
博客文章提到,要在索引上运行此操作,您需要在数据库上打开两个索引:元素值位置
和属性值位置
。除了性能提升之外,如果您在 cts.uris 调用中使用近查询,则这不是可选的 - cts.uris 不会“过滤”传递的查询的结果,因此如果没有这些索引,您仍然会得到误报。
关于javascript - 细化 MarkLogic 查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48577639/
我正在尝试缩小此图像,但它会不断失真。 这是我应用细化的相关代码。我也尝试过使用“thin”功能而不是“skeletonize”,但结果相似。 from skimage.morphology impo
好的,据我所知,目前我们有两种方法 首先是我可以在给定脚本中使用的一些 javascript。但这会关闭所有内容的右键单击。 window.oncontextmenu = function() {
在 MarkLogic 中如何找到元素所在的文档 URI 匹配的值为1742 这里是示例 XML 文档: 1742 1742 TT 1742
摘要:我有一个数据集,其收集方式使得维度最初不可用。我想获取本质上是一大块无差别的数据,并为其添加维度,以便可以对其进行查询、子集化等。这是以下问题的核心。 这是我拥有的 xarray 数据集: D
我有一个大型数据集(请参阅下面的示例格式),我需要进行以下思考: 确定第 1、2、5 列中出现的重复值 - 如果全部重复,那么我需要删除多余的行并对第 8 列中的值进行平均(这对于我将发布的代码是成功
我正在做一个练习项目,其中 iOS 应用程序打印来自 jsonplaceholder.typicode.com 的/posts 列表,当用户选择一个时,加载详细 View Controller 并显示
module Access def last self[-1] end def start_end self[0] + last end end module Stri
我是一名优秀的程序员,十分优秀!