1

I am trying to find use the cts:value-co-occurrences of a give document property for a given search string,, When I do the regular search I get 546 results back but when I do with cts:value-co-occurrence, I get only 3 documents.. Following is my code

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

This returns only 3 results.. but if I do the following I get 546 results

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

All the documents have the property <id> , so I do not understand why the difference.. I understand I am using map , so will return or should return unique <id> keys.. if that is the case I should get 241 results not 3.

4

1 回答 1

3

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

如果$query(-original)要针对文档片段运行,请将其包装在cts:document-fragment-query. 如果您希望它针对属性片段运行,则将其包装在 a 中cts:properties-fragment-query(只是为了确定)。

由于您正在使用search:parse,您还可以将其配置为针对特定的fragment-scope. 您可以在选项的顶层指定该选项,也可以在约束内部指定该选项。

于 2016-03-17T19:12:41.630 回答