cts:value-co-occurrences和cts:query选项

时间:2016-03-16 20:00:12

标签: marklogic marklogic-8

我正在尝试使用给定搜索字符串的给定文档属性的cts:value-co-occurrences,当我进行常规搜索时,我得到了546个结果但是当我使用cts:value-co-occurrence ,我只收到3份文件..以下是我的代码

xquery version "1.0-ml";
declare namespace html = "http://www.w3.org/1999/xhtml";
declare namespace prop = "http://marklogic.com/xdmp/property";
declare namespace meta = "http://ir.abbivenet.com/content-repo/metadata";
import module namespace search = "http://marklogic.com/appservices/search" at "/MarkLogic/appservices/search/search.xqy";
import module namespace functx = "http://www.functx.com"  at "/MarkLogic/functx/functx-1.0-doc-2007-01.xqy";




let $q := "(TNF)" 

let $options := 
  <options xmlns="http://marklogic.com/appservices/search">
    <constraint name="collection">
      <collection prefix=""/>
    </constraint>
    <constraint name="properties">
      <properties />
    </constraint>
    <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-facets>false</return-facets>
    <return-values>false</return-values>
    <return-constraints>false</return-constraints>
    <return-frequencies>false</return-frequencies>
    <return-qtext>false</return-qtext>
    <search-option>unfaceted</search-option>
    <search-option>score-simple</search-option>
  </options>

let $start := 1
let $page-length :=1000000

let $query-original := cts:query(search:parse($q, $options))


let $m := cts:value-co-occurrences(
              cts:element-reference(xs:QName('meta:id')),
              cts:uri-reference(),
              ('map','properties'), $query-original)
return $m

这只返回3个结果..但如果我执行以下操作,我会得到546个结果

let $result := search:search($q, $options, $start, $page-length) 
return $result

所有文档都有属性<id>,所以我不明白为什么会有差异......我知道我使用的是map,因此会返回或应该返回唯一的<id>键。如果是这种情况,我应该得到241个结果而不是3个。

1 个答案:

答案 0 :(得分:3)

这听起来像search:search仅查看文档片段,而您的cts:valuescts:value-co-occurrences调用都只查看属性片段。

如果$query(-original)是针对文档片段运行的,请将其包装在cts:document-fragment-query中。如果你想让它针对属性片段运行,那么将它包装在cts:properties-fragment-query中(只是为了确定)。

由于您使用的是search:parse,因此您还可以将其配置为针对特定fragment-scope运行。您可以在选项中的顶级指定该选项,也可以在内部约束中指定。

HTH!

相关问题