MarLogic 中没有碎片的查询问题
Issue in querying without fragmentation in MarLogic
我有如下文档:
<employees>
<employee>
<id>1</id>
</employee>
<employee>
<id>2</id>
</employee>
<employee>
<id>3</id>
</employee>
</employees>
我是运行以下查询:
cts:search(/employees/employee,
cts:element-value-query(xs:QName("id"),("2")),"unfiltered")
它returns:
<employee><id>1</id></employee>
我知道将 employee
设置为片段根 return 我会得到 id 为 2 的员工。但我不明白为什么这个未过滤的搜索 w/o 片段只给出第一个员工元素。请帮忙。
ML 版本:8.0-1.1
无论好坏,这就是未过滤搜索的工作方式..
An unfiltered search.
An unfiltered search selects fragments from the
indexes that are candidates to satisfy the specified cts:query, and
then it returns a single node from within each fragment that
satisfies the specified searchable path expression.
(注意短语单节点)
https://docs.marklogic.com/cts:search
描述的其余部分提供了有关未过滤结果何时会产生不可预测结果的更多详细信息。但总的来说,除了顶级节点(在您的情况下为 employees)之外的任何其他节点都可能不会产生可预测的结果。
如果您真的想找回员工 2 并使用未过滤的搜索,请将您的可搜索表达式设置为 doc() 并通过 xPath 过滤结果。但要注意大量员工文档(或与此相关的任何其他数据)的开销。一般来说,要使用未过滤的搜索,您应该以不同的方式(建议)或片段根结构化您的数据。
我有如下文档:
<employees>
<employee>
<id>1</id>
</employee>
<employee>
<id>2</id>
</employee>
<employee>
<id>3</id>
</employee>
</employees>
我是运行以下查询:
cts:search(/employees/employee,
cts:element-value-query(xs:QName("id"),("2")),"unfiltered")
它returns:
<employee><id>1</id></employee>
我知道将 employee
设置为片段根 return 我会得到 id 为 2 的员工。但我不明白为什么这个未过滤的搜索 w/o 片段只给出第一个员工元素。请帮忙。
ML 版本:8.0-1.1
无论好坏,这就是未过滤搜索的工作方式..
An unfiltered search. An unfiltered search selects fragments from the indexes that are candidates to satisfy the specified cts:query, and then it returns a single node from within each fragment that satisfies the specified searchable path expression.
(注意短语单节点)
https://docs.marklogic.com/cts:search
描述的其余部分提供了有关未过滤结果何时会产生不可预测结果的更多详细信息。但总的来说,除了顶级节点(在您的情况下为 employees)之外的任何其他节点都可能不会产生可预测的结果。
如果您真的想找回员工 2 并使用未过滤的搜索,请将您的可搜索表达式设置为 doc() 并通过 xPath 过滤结果。但要注意大量员工文档(或与此相关的任何其他数据)的开销。一般来说,要使用未过滤的搜索,您应该以不同的方式(建议)或片段根结构化您的数据。