搜索:当结构化查询具有约束时,值不起作用

时间:2017-06-12 20:47:17

标签: marklogic marklogic-8

很抱歉一个很长的问题,不知道除了这个之外如何解释我的问题..

我有一个查询

let $q := '(*) AND ((context:"KN"))'

我的选择

let $options := 
 <options xmlns="http://marklogic.com/appservices/search">
 <constraint name="context">
        <range type="xs:string" facet="true">
            <element name="context" ns="http://ir.abbvienet.com/content-repo/metadata"/>
            <facet-option>frequency-order</facet-option>
            <facet-option>descending</facet-option>
        </range>
    </constraint>
  <constraint name="gene">
        <range type="xs:string" facet="true">
            <path-index>//Hit[@type='GENE']/@id</path-index>
            <facet-option>frequency-order</facet-option>
            <facet-option>descending</facet-option>
            <facet-option>limit=10</facet-option>
        </range>
    </constraint>
  <return-results>false</return-results>
  <return-facets>true</return-facets>
  <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>
    <search-option>unfiltered</search-option>
</options>

当我search:search($q, $options)时 我得到以下结果

   <search:facet name="gene" type="xs:string">
    <search:facet-value name="DMPK" count="846">DMPK</search:facet-value>
    <search:facet-value name="TNF" count="323">TNF</search:facet-value>
    <search:facet-value name="IL6" count="301">IL6</search:facet-value>
    <search:facet-value name="PAGE4" count="297">PAGE4</search:facet-value>
    <search:facet-value name="INS" count="296">INS</search:facet-value>
    <search:facet-value name="PSD" count="291">PSD</search:facet-value>
    <search:facet-value name="EGFR" count="280">EGFR</search:facet-value>
    <search:facet-value name="PAGE3" count="271">PAGE3</search:facet-value>
    <search:facet-value name="PAGE5" count="270">PAGE5</search:facet-value>
    <search:facet-value name="CD4" count="268">CD4</search:facet-value>
    </search:facet>
    <search:qtext>(*) AND ((context:"KN"))</search:qtext>

哪个是对的,现在我想使用search:values来获得gene的分面......我会做以下事情

let $valueOptions :=
  <options xmlns="http://marklogic.com/appservices/search">
   <values name="facet">
       <range type="xs:string" facet="true">
        <path-index>//Hit[@type='GENE']/@id</path-index>
      </range>
      <values-option>frequency-order</values-option>
      <values-option>descending</values-option>
   </values>
  </options>


return search:values('facet', $valueOptions, search:parse($q, $options, 'search:query'),(), (), 1, 10) 

我得到以下结果

<search:values-response name="facet" type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:search="http://marklogic.com/appservices/search">
<search:distinct-value frequency="12528">EGFR</search:distinct-value>
<search:distinct-value frequency="8305">ERBB2</search:distinct-value>
<search:distinct-value frequency="7997">CD274</search:distinct-value>
<search:distinct-value frequency="7771">PDCD1</search:distinct-value>
<search:distinct-value frequency="7410">ALB</search:distinct-value>
<search:distinct-value frequency="6910">CTLA4</search:distinct-value>
<search:distinct-value frequency="6849">PARP1</search:distinct-value>
<search:distinct-value frequency="6740">MET</search:distinct-value>
<search:distinct-value frequency="6243">BTK</search:distinct-value>
<search:distinct-value frequency="6234">TNF</search:distinct-value>
<metrics xmlns="http://marklogic.com/appservices/search">
<values-resolution-time>PT0.021358S</values-resolution-time>
<total-time>PT0.022609S</total-time>
</metrics>
</search:values-response>

我注意到search:values忽略了我的搜索字符串中的约束,或者它没有以正确的方式使用search:parse的输出。

为什么输出不一样?我错过了什么

1 个答案:

答案 0 :(得分:1)

我假设您向search:values提供与$q相同的search:search,但您传递的$valueOptions没有context的约束定义}。

values定义添加到$options,并将其用于search:values

HTH!