我试图为给定的搜索字符串使用给定文档属性的cts:value-co-occurrences,当我进行常规搜索时,我得到了546个结果,但是当我使用cts:值-共现时,我只得到了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。
发布于 2016-03-17 19:12:41
这听起来像是search:search只查看文档片段,而您的cts:values和cts:value-co-occurrences调用都只查看属性片段。
如果$query(-original)是针对文档片段运行的,请将其包装在cts:document-fragment-query中。如果希望它针对属性片段运行,那么将其包装到一个cts:properties-fragment-query中(只是为了确保)。
由于您使用的是search:parse,所以还可以将其配置为针对特定的fragment-scope运行。可以在选项的顶层指定该选项,但也可以在约束中指定该选项。
哈哈!
https://stackoverflow.com/questions/36045801
复制相似问题