首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Marklogic附加查询和可搜索表达式问题

Marklogic附加查询和可搜索表达式问题
EN

Stack Overflow用户
提问于 2018-08-09 23:49:41
回答 1查看 33关注 0票数 0

我的选项文件中包含searchable-expressionadditional-query。在我的additional-query中,我有cts-field-value-query,当我有了它,我得到的结果是空的,即使我知道有同时匹配searchable-expressionadditional-query的文档。当我拿出cts:field-value-query时,结果与预期不谋而合。我包含了选项文件和xdmp:query-plan。我不明白为什么这个问题

代码语言:javascript
复制
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计划如下所示

代码语言:javascript
复制
    <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(&lt;map:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" .../&gt;), "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时的计划

代码语言:javascript
复制
<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(&lt;map:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" .../&gt;), "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>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-08-10 02:50:31

查询计划显示,在这两种情况下,片段都是从索引中选择的,所以我认为您的字段-值-查询确实匹配了一些内容。通过过滤将它们排除。

这可能是因为您的表达式是可搜索的。它指向您的信封内部非常特定的元素,而您的字段的值可能来自该路径之外的元素。

如果您试图影响搜索片段,我建议使用transform-resultspreferred-matches特性,而不是可搜索表达式。仅对可搜索表达式使用高级别元素,如/es:envelope/es:raw或/es:envelope/es:instance,或者根本不使用。

哈!

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51771305

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档