解析后的查询不包含 ML9 中的 qtextpre

Parsed query contains no qtextpre in ML9

我继承了去年从 ML7 移植到 ML9 的代码,并且搜索页面的分面窗格不像在遗留系统中那样显示分面清除控件。构建控件的 XQuery 逻辑取决于包含 @qtextpre 属性的 search:parse() 结果。在旧系统中,解析的查询是:

<cts:element-range-query qtextpre="Status:" qtextref="cts:annotation" operator="=" xmlns:cts="http://marklogic.com/cts" xmlns:xs="http://www.w3.org/2001/XMLSchema">
 <cts:element xmlns:_1="http://www.marklogic.com/ps/ns/qanda/">_1:Status</cts:element>
 <cts:annotation qtextref="following-sibling::cts:value"></cts:annotation>
 <cts:value xsi:type="xs:string" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">Review</cts:value>
 <cts:option>collation=http://marklogic.com/collation/codepoint</cts:option>
</cts:element-range-query>

但在新系统中,具有相同选项的相同查询文本解析为:

<cts:element-range-query operator="=" xmlns:cts="http://marklogic.com/cts">
 <cts:element xmlns:_1="http://www.marklogic.com/ps/ns/qanda/">_1:Status</cts:element>
 <cts:value xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">Review</cts:value>
 <cts:option>collation=http://marklogic.com/collation/codepoint</cts:option>
</cts:element-range-query>

我不太清楚该属性的用途,但此应用程序代码依赖于在查询中找到 @qtextpre 属性来决定是否在构面窗格中显示构面清除控件。谁能解释为什么它不存在于 ML9 版本的已解析查询中?

有关 search:parse() 函数的用法,请参阅每个 Marklogic 版本的文档。

我不知道为什么 - 你问的实际问题,但我可以回答这个问题:最新的 2 个版本有什么不同。这听起来更有帮助...

在文档的版本 9 中,有一个选项可以以所谓的 cts:annotated-query 格式和 cts:query 格式获取输出。似乎默认值不那么冗长。根据注释,这已被弃用,但在 9 的最新版本中可用。由于 MarkLogic 9 有许多搜索更改,我不确定哪个版本可能发生了变化。但是,我相信 cts:annotated-query 选项会给出您想要的结果。

https://docs.marklogic.com/9.0/search:parse

cts:annotated-query: Equivalent to the output produced by schema-element(cts:query), but with the addition of annotations. THIS FORM IS DEPRECATED and will be removed in a future release.

search:parse($qText, $options, "cts:annotated-query")

请注意,MarkLogic 10 的文档还列出了您需要的已弃用选项。因此,当您删除了 9 到 10 个选项时,请注意是否需要为您的功能更改代码。