Marklogic cts:值同时出现和cts:查询选项
我正在尝试为给定的搜索字符串查找和使用给定文档属性的Marklogic cts:值同时出现和cts:查询选项,marklogic,marklogic-8,Marklogic,Marklogic 8,我正在尝试为给定的搜索字符串查找和使用给定文档属性的cts:value-co-occurrents,当我进行常规搜索时,返回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/p
cts:value-co-occurrents
,当我进行常规搜索时,返回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
所有文档都有属性
,因此我不明白为什么会有差异。。我知道我正在使用映射
,因此将返回或应该返回唯一的
键。。如果是这样的话,我应该得到241个结果,而不是3个。这听起来像是search:search
只查看文档片段,而您的cts:values
和cts:value共现
调用都只查看属性片段
如果$query(-original)
是针对文档片段运行的,则将其包装在cts:documentfragmentquery
中。如果您希望它针对属性片段运行,那么将其包装在cts:properties片段查询中(只是为了确保)
由于您使用的是search:parse
,因此还可以将其配置为针对特定的片段范围运行。您可以在选项中的顶层指定该选项,但也可以在约束内指定该选项
嗯 是否有可能配置了片段根?如果每个文档有许多片段根,那么搜索将返回片段和唯一片段的计数,而因为您使用的是cts:uri引用
,cts:value共现
将只返回唯一的文档uri。为了安全起见,可能会转储索引:xs:QName('meta:id')使用cts:values并确保它包含您期望的内容(241个值),当我这样做时,让$m:=cts:values((cts:element-reference(xs:QName('meta:id')),(),('map','properties'),$query original)返回$m
,我仍然得到相同的3个结果。。这意味着什么,未创建范围索引<代码>
位于文档属性中当我执行此操作时,$m:=cts:values((cts:element reference(xs:QName('meta:id')),(),('map','properties'),$query original)返回$m
,我仍然得到相同的3个结果。。这意味着什么,未创建范围索引<代码>位于文档属性中。。但是,当我从上面的cts:values
中取出$query original
时,它确实返回了我的所有文档id,因此我认为创建了范围索引。下面是我注意到的,在将$query(在我的例子中是$query original)用于cts:values或cts:value共现时,搜索不是查看搜索片段的文档属性,而是查看文档的内容。。当我将原始查询包装到cts:documentfragmentquery.之后,我如何告诉您查看文档属性。。一切都成功了。。非常感谢你。。cts:documentfragment查询是cts:query的一个子类吗?如果是,记录在哪里。。
let $result := search:search($q, $options, $start, $page-length)
return $result