我有如下限制。..有限制
import HttpError from 'admin-on-rest/lib/util/HttpError'
当我执行搜索字符串<options xmlns="http://marklogic.com/appservices/search">
<additional-query>
<cts:and-query xmlns:cts="http://marklogic.com/cts">
<cts:collection-query>
<cts:uri>OncoWatch</cts:uri>
</cts:collection-query>
</cts:and-query>
</additional-query>
<constraint name="search-text">
<word>
<field name="wos_topic"/>
</word>
</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>
</options>
时,所得到的结果与当做'(search-text:(patient* OR adult*))'
时的结果完全不同。不是全部相同吗?
答案 0 :(得分:2)
如果在搜索字符串上应用search:parse
,则可以轻松看到差异:
xquery version "1.0-ml";
import module namespace search = "http://marklogic.com/appservices/search"
at "/MarkLogic/appservices/search/search.xqy";
let $options := <options xmlns="http://marklogic.com/appservices/search">
<additional-query>
<cts:and-query xmlns:cts="http://marklogic.com/cts">
<cts:collection-query>
<cts:uri>OncoWatch</cts:uri>
</cts:collection-query>
</cts:and-query>
</additional-query>
<constraint name="search-text">
<word>
<field name="wos_topic"/>
</word>
</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>
</options>
return (
search:parse("(search-text:(patient* OR adult*))", $options),
search:parse("(search-text:patient*) OR (search-text:adult*)", $options)
)
搜索解析器通过AND,OR,NEAR等支持相当复杂的搜索字符串,但是缺少将多个值馈入单个约束的支持。后者是正确的编写方式。第一个只是使解析器的外观与之混淆,结果OR丢失,有效地导致它搜索短语search-text:"patient* adult*"
,这与要求两个术语都一样。
HTH!