我有一个奇怪的问题与近查询.。
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>一开始我运行了这个查询
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>)我得到了结果,这是正确的

现在我运行了这个程序,得到了以下结果,这是正确的
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运行了以下查询,但没有得到任何查询。
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,对吧?
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>)

发布于 2018-07-13 15:38:48
我相信MarkLogic索引单词距离,从定位词开始到0,然后标记在1之间。为了查询相邻的单词,您需要使用接近1的查询距离。示例中的查询是正确的。
借用MarkLogic cts:近查询文档:
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" :)https://stackoverflow.com/questions/51328016
复制相似问题