我正在使用“未过滤”选项执行cts:search并启用通配符搜索(意味着传递“通配符”)。
在我的数据库中,我插入了 5 个粘贴在下面的 xml 文档。
在下面的 cts:query 中,如果journalTitle元素的值包含通配符 (*),它将返回所有 5 个文档。
例如:“d*”、“di*”、“dixi*”
即使我将“mohi * t”作为journalTitle元素的值传递,我也会得到结果中的所有五个文档。
对于“过滤”选项,它工作正常。
我很好奇为什么会出现这种行为?并且还请让我知道如何为“未过滤”选项更正此问题。
我在谷歌上搜索了很多关于这个但没有找到解决方案。
请在 cts:search 查询和 xml 文件下方找到
cts:查询
cts:search(fn:collection(), cts:element-query(
xs:QName("root"),
cts:and-query(
(
cts:element-value-query(xs:QName("sourceType"), "JA", ("case-insensitive","diacritic-sensitive","punctuation-sensitive","whitespace-sensitive","wildcarded","lang=en"), 1),
cts:element-value-query(xs:QName("journalTitle"), "mohi*t", ("case-insensitive","diacritic-sensitive","punctuation-sensitive","whitespace-sensitive","wildcarded","lang=en"), 1),
cts:element-value-query(xs:QName("title"), "title1", ("case-insensitive","diacritic-sensitive","punctuation-sensitive","whitespace-sensitive","wildcarded","lang=en"), 1),
cts:element-value-query(xs:QName("volume"), "volume0", ("case-insensitive","diacritic-sensitive","punctuation-sensitive","whitespace-sensitive","wildcarded","lang=en"), 1)
),
()
),
()
),"unfiltered")
XML 内容 - 粘贴了所有五个 xml:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<journalTitle>Dinesh</journalTitle>
<sourceType>JA</sourceType>
<title>title1</title>
<volume>volume0</volume>
</root>
-
<?xml version="1.0" encoding="UTF-8"?>
<root>
<journalTitle>Dixit</journalTitle>
<sourceType>JA</sourceType>
<title>title1</title>
<volume>volume0</volume>
</root>
-
<?xml version="1.0" encoding="UTF-8"?>
<root>
<journalTitle>Prashant</journalTitle>
<sourceType>JA</sourceType>
<title>title1</title>
<volume>volume0</volume>
</root>
-
<?xml version="1.0" encoding="UTF-8"?>
<root>
<journalTitle>GAYARI</journalTitle>
<sourceType>JA</sourceType>
<title>title1</title>
<volume>volume0</volume>
</root>
-
<?xml version="1.0" encoding="UTF-8"?>
<root>
<journalTitle>KEVAL</journalTitle>
<sourceType>JA</sourceType>
<title>title1</title>
<volume>volume0</volume>
</root>
您可能需要 xdmp:plan 结果,所以我将其粘贴在下面
xdmp:计划结果:
<qry:query-plan xmlns:qry="http://marklogic.com/cts/query">
<qry:info-trace>xdmp:eval("xdmp:plan(cts:search(fn:collection(), cts:element-query(&#10; ...", (), <options xmlns="xdmp:eval"><database>12874763000056740838</database><root>C:\RSuite\modules...</options>)</qry:info-trace>
<qry:info-trace>Analyzing path for search: fn:collection()</qry:info-trace>
<qry:info-trace>Step 1 is searchable: fn:collection()</qry:info-trace>
<qry:info-trace>Path is fully searchable.</qry:info-trace>
<qry:info-trace>Gathering constraints.</qry:info-trace>
<qry:info-trace>Search query contributed 1 constraint: cts:element-query(fn:QName("", "root"), cts:and-query((cts:element-value-query(fn:QName("", "sourceType"), "JA", ("case-insensitive","diacritic-sensitive","punctuation-sensitive","whitespace-sensitive","wildcarded","lang=en"), 1), cts:element-value-query(fn:QName("", "journalTitle"), "mohi*t", ("case-insensitive","diacritic-sensitive","punctuation-sensitive","whitespace-sensitive","wildcarded","lang=en"), 1), cts:element-value-query(fn:QName("", "title"), "title1", ("case-insensitive","diacritic-sensitive","punctuation-sensitive","whitespace-sensitive","wildcarded","lang=en"), 1), cts:element-value-query(fn:QName("", "volume"), "volume0", ("case-insensitive","diacritic-sensitive","punctuation-sensitive","whitespace-sensitive","wildcarded","lang=en"), 1)), ()), ())</qry:info-trace>
<qry:partial-plan>
<qry:or-two-queries>
<qry:element-query>
<qry:key>10866465315185201428</qry:key>
<qry:annotation>element(root)</qry:annotation>
<qry:and-query>
<qry:term-query weight="1">
<qry:key>15329831187071590131</qry:key>
<qry:annotation>element(sourceType,value("JA"))</qry:annotation>
</qry:term-query>
<qry:term-query weight="0">
<qry:key>3029765743981997321</qry:key>
<qry:annotation>element(journalTitle)</qry:annotation>
</qry:term-query>
<qry:term-query weight="1">
<qry:key>4206353216190327061</qry:key>
<qry:annotation>element(title,value("title1"))</qry:annotation>
</qry:term-query>
<qry:term-query weight="1">
<qry:key>7729558342335907080</qry:key>
<qry:annotation>element(volume,value("volume0"))</qry:annotation>
</qry:term-query>
</qry:and-query>
</qry:element-query>
<qry:and-two-queries>
<qry:term-query weight="0">
<qry:key>837267169796541076</qry:key>
<qry:annotation>link-child(descendant(element(root)))</qry:annotation>
</qry:term-query>
<qry:and-query>
<qry:term-query weight="1">
<qry:key>15329831187071590131</qry:key>
<qry:annotation>element(sourceType,value("JA"))</qry:annotation>
</qry:term-query>
<qry:term-query weight="0">
<qry:key>3029765743981997321</qry:key>
<qry:annotation>element(journalTitle)</qry:annotation>
</qry:term-query>
<qry:term-query weight="1">
<qry:key>4206353216190327061</qry:key>
<qry:annotation>element(title,value("title1"))</qry:annotation>
</qry:term-query>
<qry:term-query weight="1">
<qry:key>7729558342335907080</qry:key>
<qry:annotation>element(volume,value("volume0"))</qry:annotation>
</qry:term-query>
</qry:and-query>
</qry:and-two-queries>
</qry:or-two-queries>
</qry:partial-plan>
<qry:info-trace>Executing search.</qry:info-trace>
<qry:final-plan>
<qry:and-query>
<qry:or-two-queries>
<qry:element-query>
<qry:key>10866465315185201428</qry:key>
<qry:annotation>element(root)</qry:annotation>
<qry:and-query>
<qry:term-query weight="1">
<qry:key>15329831187071590131</qry:key>
<qry:annotation>element(sourceType,value("JA"))</qry:annotation>
</qry:term-query>
<qry:term-query weight="0">
<qry:key>3029765743981997321</qry:key>
<qry:annotation>element(journalTitle)</qry:annotation>
</qry:term-query>
<qry:term-query weight="1">
<qry:key>4206353216190327061</qry:key>
<qry:annotation>element(title,value("title1"))</qry:annotation>
</qry:term-query>
<qry:term-query weight="1">
<qry:key>7729558342335907080</qry:key>
<qry:annotation>element(volume,value("volume0"))</qry:annotation>
</qry:term-query>
</qry:and-query>
</qry:element-query>
<qry:and-two-queries>
<qry:term-query weight="0">
<qry:key>837267169796541076</qry:key>
<qry:annotation>link-child(descendant(element(root)))</qry:annotation>
</qry:term-query>
<qry:and-query>
<qry:term-query weight="1">
<qry:key>15329831187071590131</qry:key>
<qry:annotation>element(sourceType,value("JA"))</qry:annotation>
</qry:term-query>
<qry:term-query weight="0">
<qry:key>3029765743981997321</qry:key>
<qry:annotation>element(journalTitle)</qry:annotation>
</qry:term-query>
<qry:term-query weight="1">
<qry:key>4206353216190327061</qry:key>
<qry:annotation>element(title,value("title1"))</qry:annotation>
</qry:term-query>
<qry:term-query weight="1">
<qry:key>7729558342335907080</qry:key>
<qry:annotation>element(volume,value("volume0"))</qry:annotation>
</qry:term-query>
</qry:and-query>
</qry:and-two-queries>
</qry:or-two-queries>
</qry:and-query>
</qry:final-plan>
<qry:info-trace>Selected 5 fragments</qry:info-trace>
<qry:result estimate="5"/>
</qry:query-plan>
如有语法错误,请见谅。
如果您需要更多信息,请告诉我。