1

我想在 marklogic 中搜索以双引号开头的术语。我正在使用搜索建议。

我正在搜索的术语是“独立”。成功执行后,查询应建议多个选项,其中一个选项是“独立方”。但它没有返回任何建议。我可以看到 search-suggest 没有找到以双引号开头的术语。请建议我该如何解决。

代码在下面共享。

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>myCollection</cts:uri>
  </cts:collection-query>
  <cts:or-query>
   <cts:collection-query>
     <cts:uri>anotherCollection</cts:uri>
    </cts:collection-query>
  </cts:or-query>
 </cts:and-query>
</additional-query>
<term>
 <term-option>case-insensitive</term-option>
 <term-option>punctuation-sensitive</term-option>
 <empty apply="all-results">
 </empty>
</term>
<constraint name="myTargetItem">
 <range collation="http://marklogic.com/collation/codepoint" type="xs:string" facet="false">
 <element ns="---" name="targetItem">
</element>
</range>
</constraint>
</options>


let $searchTerm := '"Independent'
let $searchTerm := concat('"*',$searchTerm )
let $searchTerm :=  concat("myTargetItem", ':', $searchTerm )
return search:suggest($searchTerm , $options,20)

实际结果 EMPTY

预期 myTargetItem:""独立"

4

1 回答 1

1

试试这个:

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>myCollection</cts:uri>
  </cts:collection-query>
  <cts:or-query>
   <cts:collection-query>
     <cts:uri>anotherCollection</cts:uri>
    </cts:collection-query>
  </cts:or-query>
 </cts:and-query>
</additional-query>
<default-suggestion-source>
  <range collation="http://marklogic.com/collation/codepoint" type="xs:string" 
    facet="false">
   <element ns="" name="targetItem"/>
  </range>
  <suggestion-option>case-insensitive</suggestion-option>
  <suggestion-option>punctuation-sensitive</suggestion-option>
</default-suggestion-source>
</options>


let $searchTerm := '"Independent'
let $searchTerm := concat('"*',$searchTerm )
let $searchTerm :=  concat("myTargetItem", ':', $searchTerm )
return search:suggest($searchTerm , $options,20)
于 2019-07-11T14:21:53.787 回答