Marklogic 附加查询和可搜索表达式问题
Marklogic Additional Query and Searchable expression issue
我的选项文件中有 searchable-expression
和 additional-query
。在我的 additional-query
中有 cts-field-value-query
,当我有这个时,我得到空结果,即使我知道有些文档同时匹配 searchable-expression
和 additional-query
.. 当我取出 cts:field-value-query
结果如预期的那样.. 我包括了选项文件和 xdmp:query-plan
..我不明白为什么会出现这个问题
let $options :=
<options xmlns="http://marklogic.com/appservices/search">
<additional-query>
<cts:and-query xmlns:cts="http://marklogic.com/cts">
<cts:collection-query>
<cts:uri>OncoWatch</cts:uri>
</cts:collection-query>
<cts:field-value-query>
<cts:field>wos_doctype</cts:field>
<cts:text>Article</cts:text>
<cts:text>Review</cts:text>
</cts:field-value-query>
</cts:and-query>
</additional-query>
<searchable-expression xmlns:es="http://marklogic.com/entity-services"
xmlns:wos_dps="http://clarivate.com/schema/wok5.27/public/FullRecord">
/es:envelope/es:raw/wos_dps:REC/wos_dps:static_data/wos_dps:summary/wos_dps:titles/wos_dps:title
</searchable-expression>
<term>
<term-option>case-insensitive</term-option>
<term-option>punctuation-insensitive</term-option>
<term-option>whitespace-insensitive</term-option>
<term-option>wildcarded</term-option>
</term>
<return-plan>true</return-plan>
</options>
let $q := '"pancreatic cancer"'
return
search:search($q, $options)
xdmp 计划如下所示
<search:response snippet-format="snippet" total="0" start="1" page-length="10" xmlns:search="http://marklogic.com/appservices/search">
<search:plan>
<qry:query-plan xmlns:qry="http://marklogic.com/cts/query">
<qry:expr-trace>impl:apply-search(map:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" .../>), "xdmp:plan", fn:false())</qry:expr-trace>
<qry:info-trace>Analyzing path for search: fn:collection()/es:envelope/es:raw/wos_dps:REC/wos_dps:static_data/wos_dps:summary/wos_dps:titles/wos_dps:title</qry:info-trace>
<qry:info-trace>Step 1 is searchable: fn:collection()</qry:info-trace>
<qry:info-trace>Step 2 is searchable: es:envelope</qry:info-trace>
<qry:info-trace>Step 3 is searchable: es:raw</qry:info-trace>
<qry:info-trace>Step 4 is searchable: wos_dps:REC</qry:info-trace>
<qry:info-trace>Step 5 is searchable: wos_dps:static_data</qry:info-trace>
<qry:info-trace>Step 6 is searchable: wos_dps:summary</qry:info-trace>
<qry:info-trace>Step 7 is searchable: wos_dps:titles</qry:info-trace>
<qry:info-trace>Step 8 is searchable: wos_dps:title</qry:info-trace>
<qry:info-trace>Path is fully searchable.</qry:info-trace>
<qry:info-trace>Gathering constraints.</qry:info-trace>
<qry:info-trace>Search query contributed 3 constraints: cts:and-query((cts:word-query("pancreatic cancer", ("case-insensitive","punctuation-insensitive","whitespace-insensitive","wildcarded","lang=en"), 1), cts:collection-query("OncoWatch"), cts:field-value-query("wos_doctype", ("Article", "Review"), ("lang=en"), 1)), ())</qry:info-trace>
<qry:partial-plan>
<qry:term-query weight="1">
<qry:key>17396426271722676659</qry:key>
</qry:term-query>
</qry:partial-plan>
<qry:partial-plan>
<qry:term-query weight="0">
<qry:key>16172058720999549713</qry:key>
<qry:annotation>collection(OncoWatch)</qry:annotation>
</qry:term-query>
</qry:partial-plan>
<qry:partial-plan>
<qry:or-two-queries>
<qry:term-query weight="1">
<qry:key>8492163112599871394</qry:key>
</qry:term-query>
<qry:term-query weight="1">
<qry:key>10427204889894421302</qry:key>
</qry:term-query>
</qry:or-two-queries>
</qry:partial-plan>
<qry:info-trace>Executing search.</qry:info-trace>
<qry:ordering/>
<qry:final-plan>
<qry:and-query>
<qry:term-query weight="0">
<qry:key>3030157765137304984</qry:key>
<qry:annotation>descendant(doc-root(element(es:envelope),doc-kind(document)))</qry:annotation>
</qry:term-query>
<qry:term-query weight="0">
<qry:key>14623301529635238289</qry:key>
<qry:annotation>descendant(element-child(es:envelope/es:raw))</qry:annotation>
</qry:term-query>
<qry:term-query weight="0">
<qry:key>2513953156802156363</qry:key>
<qry:annotation>descendant(element-child(es:raw/wos_dps:REC))</qry:annotation>
</qry:term-query>
<qry:term-query weight="0">
<qry:key>15620627614067983352</qry:key>
<qry:annotation>descendant(element-child(wos_dps:REC/wos_dps:static_data))</qry:annotation>
</qry:term-query>
<qry:term-query weight="0">
<qry:key>14267880419025656818</qry:key>
<qry:annotation>descendant(element-child(wos_dps:static_data/wos_dps:summary))</qry:annotation>
</qry:term-query>
<qry:term-query weight="0">
<qry:key>1256980818223445232</qry:key>
<qry:annotation>descendant(element-child(wos_dps:summary/wos_dps:titles))</qry:annotation>
</qry:term-query>
<qry:or-two-queries>
<qry:term-query weight="0">
<qry:key>7002325115516888131</qry:key>
<qry:annotation>element-child(wos_dps:titles/wos_dps:title)</qry:annotation>
</qry:term-query>
<qry:term-query weight="0">
<qry:key>14914226620346018347</qry:key>
<qry:annotation>link-child(descendant(element-child(wos_dps:titles/wos_dps:title)))</qry:annotation>
</qry:term-query>
</qry:or-two-queries>
<qry:term-query weight="1">
<qry:key>17396426271722676659</qry:key>
</qry:term-query>
<qry:term-query weight="0">
<qry:key>16172058720999549713</qry:key>
<qry:annotation>collection(OncoWatch)</qry:annotation>
</qry:term-query>
<qry:or-two-queries>
<qry:term-query weight="1">
<qry:key>8492163112599871394</qry:key>
</qry:term-query>
<qry:term-query weight="1">
<qry:key>10427204889894421302</qry:key>
</qry:term-query>
</qry:or-two-queries>
</qry:and-query>
</qry:final-plan>
<qry:info-trace>Selected 1264 fragments to filter</qry:info-trace>
<qry:result estimate="1264"/>
</qry:query-plan>
</search:plan>
<search:qtext>"pancreatic cancer"</search:qtext>
<search:metrics>
<search:query-resolution-time>PT0.183458S</search:query-resolution-time>
<search:total-time>PT0.186923S</search:total-time>
</search:metrics>
</search:response>
这是我取出 cts:field-value-query
时的计划
<search:plan xmlns:search="http://marklogic.com/appservices/search">
<qry:query-plan xmlns:qry="http://marklogic.com/cts/query">
<qry:expr-trace>impl:apply-search(map:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" .../>), "xdmp:plan", fn:false())</qry:expr-trace>
<qry:info-trace>Analyzing path for search: fn:collection()/es:envelope/es:raw/wos_dps:REC/wos_dps:static_data/wos_dps:summary/wos_dps:titles/wos_dps:title</qry:info-trace>
<qry:info-trace>Step 1 is searchable: fn:collection()</qry:info-trace>
<qry:info-trace>Step 2 is searchable: es:envelope</qry:info-trace>
<qry:info-trace>Step 3 is searchable: es:raw</qry:info-trace>
<qry:info-trace>Step 4 is searchable: wos_dps:REC</qry:info-trace>
<qry:info-trace>Step 5 is searchable: wos_dps:static_data</qry:info-trace>
<qry:info-trace>Step 6 is searchable: wos_dps:summary</qry:info-trace>
<qry:info-trace>Step 7 is searchable: wos_dps:titles</qry:info-trace>
<qry:info-trace>Step 8 is searchable: wos_dps:title</qry:info-trace>
<qry:info-trace>Path is fully searchable.</qry:info-trace>
<qry:info-trace>Gathering constraints.</qry:info-trace>
<qry:info-trace>Search query contributed 2 constraints: cts:and-query((cts:word-query("pancreatic cancer", ("case-insensitive","punctuation-insensitive","whitespace-insensitive","wildcarded","lang=en"), 1), cts:collection-query("OncoWatch")), ())</qry:info-trace>
<qry:partial-plan>
<qry:term-query weight="1">
<qry:key>17396426271722676659</qry:key>
</qry:term-query>
</qry:partial-plan>
<qry:partial-plan>
<qry:term-query weight="0">
<qry:key>16172058720999549713</qry:key>
<qry:annotation>collection(OncoWatch)</qry:annotation>
</qry:term-query>
</qry:partial-plan>
<qry:info-trace>Executing search.</qry:info-trace>
<qry:ordering/>
<qry:final-plan>
<qry:and-query>
<qry:term-query weight="0">
<qry:key>3030157765137304984</qry:key>
<qry:annotation>descendant(doc-root(element(es:envelope),doc-kind(document)))</qry:annotation>
</qry:term-query>
<qry:term-query weight="0">
<qry:key>14623301529635238289</qry:key>
<qry:annotation>descendant(element-child(es:envelope/es:raw))</qry:annotation>
</qry:term-query>
<qry:term-query weight="0">
<qry:key>2513953156802156363</qry:key>
<qry:annotation>descendant(element-child(es:raw/wos_dps:REC))</qry:annotation>
</qry:term-query>
<qry:term-query weight="0">
<qry:key>15620627614067983352</qry:key>
<qry:annotation>descendant(element-child(wos_dps:REC/wos_dps:static_data))</qry:annotation>
</qry:term-query>
<qry:term-query weight="0">
<qry:key>14267880419025656818</qry:key>
<qry:annotation>descendant(element-child(wos_dps:static_data/wos_dps:summary))</qry:annotation>
</qry:term-query>
<qry:term-query weight="0">
<qry:key>1256980818223445232</qry:key>
<qry:annotation>descendant(element-child(wos_dps:summary/wos_dps:titles))</qry:annotation>
</qry:term-query>
<qry:or-two-queries>
<qry:term-query weight="0">
<qry:key>7002325115516888131</qry:key>
<qry:annotation>element-child(wos_dps:titles/wos_dps:title)</qry:annotation>
</qry:term-query>
<qry:term-query weight="0">
<qry:key>14914226620346018347</qry:key>
<qry:annotation>link-child(descendant(element-child(wos_dps:titles/wos_dps:title)))</qry:annotation>
</qry:term-query>
</qry:or-two-queries>
<qry:term-query weight="1">
<qry:key>17396426271722676659</qry:key>
</qry:term-query>
<qry:term-query weight="0">
<qry:key>16172058720999549713</qry:key>
<qry:annotation>collection(OncoWatch)</qry:annotation>
</qry:term-query>
</qry:and-query>
</qry:final-plan>
<qry:info-trace>Selected 1337 fragments to filter</qry:info-trace>
<qry:result estimate="1337"/>
</qry:query-plan>
</search:plan>
查询计划显示,在这两种情况下,片段都是从索引中选择的,因此我认为您的字段值查询确实匹配了某些内容。它们被过滤掉了。
这可能是因为您的可搜索表达式。它指向信封深处的一个非常具体的元素,并且您的字段的值可能来自该路径之外的元素。
如果您试图影响搜索片段,我建议您使用 transform-results
和 preferred-matches
功能而不是可搜索表达式。仅对可搜索表达式使用高级元素,例如 /es:envelope/es:raw,或 /es:envelope/es:instance,或根本不使用 none。
HTH!
我的选项文件中有 searchable-expression
和 additional-query
。在我的 additional-query
中有 cts-field-value-query
,当我有这个时,我得到空结果,即使我知道有些文档同时匹配 searchable-expression
和 additional-query
.. 当我取出 cts:field-value-query
结果如预期的那样.. 我包括了选项文件和 xdmp:query-plan
..我不明白为什么会出现这个问题
let $options :=
<options xmlns="http://marklogic.com/appservices/search">
<additional-query>
<cts:and-query xmlns:cts="http://marklogic.com/cts">
<cts:collection-query>
<cts:uri>OncoWatch</cts:uri>
</cts:collection-query>
<cts:field-value-query>
<cts:field>wos_doctype</cts:field>
<cts:text>Article</cts:text>
<cts:text>Review</cts:text>
</cts:field-value-query>
</cts:and-query>
</additional-query>
<searchable-expression xmlns:es="http://marklogic.com/entity-services"
xmlns:wos_dps="http://clarivate.com/schema/wok5.27/public/FullRecord">
/es:envelope/es:raw/wos_dps:REC/wos_dps:static_data/wos_dps:summary/wos_dps:titles/wos_dps:title
</searchable-expression>
<term>
<term-option>case-insensitive</term-option>
<term-option>punctuation-insensitive</term-option>
<term-option>whitespace-insensitive</term-option>
<term-option>wildcarded</term-option>
</term>
<return-plan>true</return-plan>
</options>
let $q := '"pancreatic cancer"'
return
search:search($q, $options)
xdmp 计划如下所示
<search:response snippet-format="snippet" total="0" start="1" page-length="10" xmlns:search="http://marklogic.com/appservices/search">
<search:plan>
<qry:query-plan xmlns:qry="http://marklogic.com/cts/query">
<qry:expr-trace>impl:apply-search(map:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" .../>), "xdmp:plan", fn:false())</qry:expr-trace>
<qry:info-trace>Analyzing path for search: fn:collection()/es:envelope/es:raw/wos_dps:REC/wos_dps:static_data/wos_dps:summary/wos_dps:titles/wos_dps:title</qry:info-trace>
<qry:info-trace>Step 1 is searchable: fn:collection()</qry:info-trace>
<qry:info-trace>Step 2 is searchable: es:envelope</qry:info-trace>
<qry:info-trace>Step 3 is searchable: es:raw</qry:info-trace>
<qry:info-trace>Step 4 is searchable: wos_dps:REC</qry:info-trace>
<qry:info-trace>Step 5 is searchable: wos_dps:static_data</qry:info-trace>
<qry:info-trace>Step 6 is searchable: wos_dps:summary</qry:info-trace>
<qry:info-trace>Step 7 is searchable: wos_dps:titles</qry:info-trace>
<qry:info-trace>Step 8 is searchable: wos_dps:title</qry:info-trace>
<qry:info-trace>Path is fully searchable.</qry:info-trace>
<qry:info-trace>Gathering constraints.</qry:info-trace>
<qry:info-trace>Search query contributed 3 constraints: cts:and-query((cts:word-query("pancreatic cancer", ("case-insensitive","punctuation-insensitive","whitespace-insensitive","wildcarded","lang=en"), 1), cts:collection-query("OncoWatch"), cts:field-value-query("wos_doctype", ("Article", "Review"), ("lang=en"), 1)), ())</qry:info-trace>
<qry:partial-plan>
<qry:term-query weight="1">
<qry:key>17396426271722676659</qry:key>
</qry:term-query>
</qry:partial-plan>
<qry:partial-plan>
<qry:term-query weight="0">
<qry:key>16172058720999549713</qry:key>
<qry:annotation>collection(OncoWatch)</qry:annotation>
</qry:term-query>
</qry:partial-plan>
<qry:partial-plan>
<qry:or-two-queries>
<qry:term-query weight="1">
<qry:key>8492163112599871394</qry:key>
</qry:term-query>
<qry:term-query weight="1">
<qry:key>10427204889894421302</qry:key>
</qry:term-query>
</qry:or-two-queries>
</qry:partial-plan>
<qry:info-trace>Executing search.</qry:info-trace>
<qry:ordering/>
<qry:final-plan>
<qry:and-query>
<qry:term-query weight="0">
<qry:key>3030157765137304984</qry:key>
<qry:annotation>descendant(doc-root(element(es:envelope),doc-kind(document)))</qry:annotation>
</qry:term-query>
<qry:term-query weight="0">
<qry:key>14623301529635238289</qry:key>
<qry:annotation>descendant(element-child(es:envelope/es:raw))</qry:annotation>
</qry:term-query>
<qry:term-query weight="0">
<qry:key>2513953156802156363</qry:key>
<qry:annotation>descendant(element-child(es:raw/wos_dps:REC))</qry:annotation>
</qry:term-query>
<qry:term-query weight="0">
<qry:key>15620627614067983352</qry:key>
<qry:annotation>descendant(element-child(wos_dps:REC/wos_dps:static_data))</qry:annotation>
</qry:term-query>
<qry:term-query weight="0">
<qry:key>14267880419025656818</qry:key>
<qry:annotation>descendant(element-child(wos_dps:static_data/wos_dps:summary))</qry:annotation>
</qry:term-query>
<qry:term-query weight="0">
<qry:key>1256980818223445232</qry:key>
<qry:annotation>descendant(element-child(wos_dps:summary/wos_dps:titles))</qry:annotation>
</qry:term-query>
<qry:or-two-queries>
<qry:term-query weight="0">
<qry:key>7002325115516888131</qry:key>
<qry:annotation>element-child(wos_dps:titles/wos_dps:title)</qry:annotation>
</qry:term-query>
<qry:term-query weight="0">
<qry:key>14914226620346018347</qry:key>
<qry:annotation>link-child(descendant(element-child(wos_dps:titles/wos_dps:title)))</qry:annotation>
</qry:term-query>
</qry:or-two-queries>
<qry:term-query weight="1">
<qry:key>17396426271722676659</qry:key>
</qry:term-query>
<qry:term-query weight="0">
<qry:key>16172058720999549713</qry:key>
<qry:annotation>collection(OncoWatch)</qry:annotation>
</qry:term-query>
<qry:or-two-queries>
<qry:term-query weight="1">
<qry:key>8492163112599871394</qry:key>
</qry:term-query>
<qry:term-query weight="1">
<qry:key>10427204889894421302</qry:key>
</qry:term-query>
</qry:or-two-queries>
</qry:and-query>
</qry:final-plan>
<qry:info-trace>Selected 1264 fragments to filter</qry:info-trace>
<qry:result estimate="1264"/>
</qry:query-plan>
</search:plan>
<search:qtext>"pancreatic cancer"</search:qtext>
<search:metrics>
<search:query-resolution-time>PT0.183458S</search:query-resolution-time>
<search:total-time>PT0.186923S</search:total-time>
</search:metrics>
</search:response>
这是我取出 cts:field-value-query
<search:plan xmlns:search="http://marklogic.com/appservices/search">
<qry:query-plan xmlns:qry="http://marklogic.com/cts/query">
<qry:expr-trace>impl:apply-search(map:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" .../>), "xdmp:plan", fn:false())</qry:expr-trace>
<qry:info-trace>Analyzing path for search: fn:collection()/es:envelope/es:raw/wos_dps:REC/wos_dps:static_data/wos_dps:summary/wos_dps:titles/wos_dps:title</qry:info-trace>
<qry:info-trace>Step 1 is searchable: fn:collection()</qry:info-trace>
<qry:info-trace>Step 2 is searchable: es:envelope</qry:info-trace>
<qry:info-trace>Step 3 is searchable: es:raw</qry:info-trace>
<qry:info-trace>Step 4 is searchable: wos_dps:REC</qry:info-trace>
<qry:info-trace>Step 5 is searchable: wos_dps:static_data</qry:info-trace>
<qry:info-trace>Step 6 is searchable: wos_dps:summary</qry:info-trace>
<qry:info-trace>Step 7 is searchable: wos_dps:titles</qry:info-trace>
<qry:info-trace>Step 8 is searchable: wos_dps:title</qry:info-trace>
<qry:info-trace>Path is fully searchable.</qry:info-trace>
<qry:info-trace>Gathering constraints.</qry:info-trace>
<qry:info-trace>Search query contributed 2 constraints: cts:and-query((cts:word-query("pancreatic cancer", ("case-insensitive","punctuation-insensitive","whitespace-insensitive","wildcarded","lang=en"), 1), cts:collection-query("OncoWatch")), ())</qry:info-trace>
<qry:partial-plan>
<qry:term-query weight="1">
<qry:key>17396426271722676659</qry:key>
</qry:term-query>
</qry:partial-plan>
<qry:partial-plan>
<qry:term-query weight="0">
<qry:key>16172058720999549713</qry:key>
<qry:annotation>collection(OncoWatch)</qry:annotation>
</qry:term-query>
</qry:partial-plan>
<qry:info-trace>Executing search.</qry:info-trace>
<qry:ordering/>
<qry:final-plan>
<qry:and-query>
<qry:term-query weight="0">
<qry:key>3030157765137304984</qry:key>
<qry:annotation>descendant(doc-root(element(es:envelope),doc-kind(document)))</qry:annotation>
</qry:term-query>
<qry:term-query weight="0">
<qry:key>14623301529635238289</qry:key>
<qry:annotation>descendant(element-child(es:envelope/es:raw))</qry:annotation>
</qry:term-query>
<qry:term-query weight="0">
<qry:key>2513953156802156363</qry:key>
<qry:annotation>descendant(element-child(es:raw/wos_dps:REC))</qry:annotation>
</qry:term-query>
<qry:term-query weight="0">
<qry:key>15620627614067983352</qry:key>
<qry:annotation>descendant(element-child(wos_dps:REC/wos_dps:static_data))</qry:annotation>
</qry:term-query>
<qry:term-query weight="0">
<qry:key>14267880419025656818</qry:key>
<qry:annotation>descendant(element-child(wos_dps:static_data/wos_dps:summary))</qry:annotation>
</qry:term-query>
<qry:term-query weight="0">
<qry:key>1256980818223445232</qry:key>
<qry:annotation>descendant(element-child(wos_dps:summary/wos_dps:titles))</qry:annotation>
</qry:term-query>
<qry:or-two-queries>
<qry:term-query weight="0">
<qry:key>7002325115516888131</qry:key>
<qry:annotation>element-child(wos_dps:titles/wos_dps:title)</qry:annotation>
</qry:term-query>
<qry:term-query weight="0">
<qry:key>14914226620346018347</qry:key>
<qry:annotation>link-child(descendant(element-child(wos_dps:titles/wos_dps:title)))</qry:annotation>
</qry:term-query>
</qry:or-two-queries>
<qry:term-query weight="1">
<qry:key>17396426271722676659</qry:key>
</qry:term-query>
<qry:term-query weight="0">
<qry:key>16172058720999549713</qry:key>
<qry:annotation>collection(OncoWatch)</qry:annotation>
</qry:term-query>
</qry:and-query>
</qry:final-plan>
<qry:info-trace>Selected 1337 fragments to filter</qry:info-trace>
<qry:result estimate="1337"/>
</qry:query-plan>
</search:plan>
查询计划显示,在这两种情况下,片段都是从索引中选择的,因此我认为您的字段值查询确实匹配了某些内容。它们被过滤掉了。
这可能是因为您的可搜索表达式。它指向信封深处的一个非常具体的元素,并且您的字段的值可能来自该路径之外的元素。
如果您试图影响搜索片段,我建议您使用 transform-results
和 preferred-matches
功能而不是可搜索表达式。仅对可搜索表达式使用高级元素,例如 /es:envelope/es:raw,或 /es:envelope/es:instance,或根本不使用 none。
HTH!