首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >cts:值-共现和cts:query选项

cts:值-共现和cts:query选项
EN

Stack Overflow用户
提问于 2016-03-16 20:00:12
回答 1查看 213关注 0票数 1

我试图为给定的搜索字符串使用给定文档属性的cts:value-co-occurrences,当我进行常规搜索时,我得到了546个结果,但是当我使用cts:值-共现时,我只得到了3个文档。以下是我的代码

代码语言:javascript
复制
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个结果

代码语言:javascript
复制
let $result := search:search($q, $options, $start, $page-length) 
return $result

所有的文档都有属性<id>,所以我不明白为什么会有区别。我知道我正在使用map,所以会返回或应该返回唯一的<id>键。如果是这样的话,我应该得到241的结果,而不是3。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-03-17 19:12:41

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

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

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

哈哈!

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36045801

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档