首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Marklogic中的近查询问题

Marklogic中的近查询问题
EN

Stack Overflow用户
提问于 2018-07-13 15:02:21
回答 1查看 65关注 0票数 0

我有一个奇怪的问题与近查询.。

代码语言:javascript
复制
let $xml :=
  <titles count="6">
    <title type="source">ASIA-PACIFIC JOURNAL OF CLINICAL ONCOLOGY</title>
    <title type="source_abbrev">ASIA-PAC J CLIN ONCO</title>
    <title type="abbrev_iso">Asia-Pac. J. Clin. Oncol.</title>
    <title type="abbrev_11">ASIA-PAC J</title>
    <title type="abbrev_29">ASIA-PAC J CLIN ONCOL</title>
    <title type="item">Phase II study of cetuximab with irinotecan for KRAS wild-type colorectal cancer in Japanese patients</title>
   </titles>

一开始我运行了这个查询

代码语言:javascript
复制
let $q1 := 
      cts:element-query((xs:QName("title")),
          cts:word-query(("phase 0","phase 1","phase 2","phase 3","phase 4","phase I","phase ii","phase iii","phase iv"),
          ("case-insensitive", "wildcarded"))
        )
return
  cts:highlight($xml,$q1, <b>{$cts:text}</b>)

我得到了结果,这是正确的

现在我运行了这个程序,得到了以下结果,这是正确的

代码语言:javascript
复制
let $q2 := 
      cts:element-query((xs:QName("title")),
          cts:word-query(("trial*", "study", "studies*"),
          ("case-insensitive", "wildcarded"))
        )

return
  cts:highlight($xml,$q2, <b>{$cts:text}</b>)

然后,我使用not /0运行了以下查询,但没有得到任何查询。

代码语言:javascript
复制
let $q3 :=
    cts:near-query((
              cts:element-query((xs:QName("title")),
                cts:word-query(("phase 0","phase 1","phase 2","phase 3","phase 4","phase I","phase ii","phase iii","phase iv"),
                  ("case-insensitive", "wildcarded")))
          ,
             cts:element-query((xs:QName("title")),
                cts:word-query(("trial*", "study", "studies*"),
                  ("case-insensitive", "wildcarded")))
         ),
         0,
         ('ordered'))

return
  cts:highlight($xml,$q3, <b>{$cts:text}</b>)

但是我用NEAR/1运行了查询,得到了结果..但这是为什么?法老1紧接着是法老2。所以近距离应该是0,对吧?

代码语言:javascript
复制
let $q3 :=
    cts:near-query((
              cts:element-query((xs:QName("title")),
                cts:word-query(("phase 0","phase 1","phase 2","phase 3","phase 4","phase I","phase ii","phase iii","phase iv"),
                  ("case-insensitive", "wildcarded")))
          ,
             cts:element-query((xs:QName("title")),
                cts:word-query(("trial*", "study", "studies*"),
                  ("case-insensitive", "wildcarded")))
         ),
         1,
         ('ordered'))

return
  cts:highlight($xml,$q3, <b>{$cts:text}</b>)

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-07-13 15:38:48

我相信MarkLogic索引单词距离,从定位词开始到0,然后标记在1之间。为了查询相邻的单词,您需要使用接近1的查询距离。示例中的查询是正确的。

借用MarkLogic cts:近查询文档:

代码语言:javascript
复制
xquery version "1.0-ml";
let $x := <p>Now is the winter of our discontent</p>
return
cts:contains($x, cts:near-query(
                    ("now", "the"),
                    2, "ordered"));

(: => returns true, "the" is 2 words from "now" :)

let $x := <p>Now is the winter of our discontent</p>
return
cts:contains($x, cts:near-query(
                    ("now", "is"),
                    1, "ordered"));
(: => returns true, "is" is 1 word from "now" :)

let $x := <p>Now is the winter of our discontent</p>
return
cts:contains($x, cts:near-query(
                    ("now", "is"),
                    0, "ordered"));

(: => returns false, "is" is 1 word from "now" :)
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51328016

复制
相关文章

相似问题

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