没有关于单词限制的建议

时间:2019-01-15 14:26:15

标签: marklogic

在我的search:suggest通话中,我在元素上指定了 word 前缀约束。由于某种原因,我没有得到有关前缀约束搜索的建议:

此代码说明了我的问题:

let $doc := 
<doc>
  <title>Show me some suggestions!</title>
</doc>

return xdmp:document-insert('so.xml', $doc);

import module namespace search = "http://marklogic.com/appservices/search"
    at "/MarkLogic/appservices/search/search.xqy";

search:suggest('title:', 
  <options xmlns="http://marklogic.com/appservices/search">
    <constraint name="title">
      <word collation="http://marklogic.com/collation/en">
        <element name="title" />
      </word>
    </constraint>

    <default-suggestion-source>
      <word-lexicon collation="http://marklogic.com/collation/en"/>
    </default-suggestion-source>
  </options>
)

这不会产生任何建议。只有添加以下suggestions-source后,我才能得到预期的建议:

<suggestion-source ref="title">
   <word collation="http://marklogic.com/collation/en">
      <element name="title"/>
   </word>
</suggestion-source>

rangecollection约束下,这似乎并不相同,建议是开箱即用的,没有suggestion-source

有没有为什么没有显示针对word约束的建议的原因,例如性能?此行为记录在某处吗?

使用MarkLogic 9.0-8。

1 个答案:

答案 0 :(得分:1)

如果您已经为特定的JSON属性或元素创建了词词典,那么这些选项应该能够以这种方式引用约束:

<default-suggestion-source ref="title"/>

或以这种方式内联识别单词词典:

<default-suggestion-source>
  <word collation="http://marklogic.com/collation/en">
    <element name="title" />
  </word>
</default-suggestion-source>

单词词典查询选项指定数据库范围的单词词典。如果已为数据库启用了数据库范围的词词典,则word-lexicon元素应该起作用-尽管不建议这样做(除非数据库很小)。

有关更多信息,请参见:

http://docs.marklogic.com/guide/search-dev/search-api#id_89118

http://docs.marklogic.com/guide/search-dev/appendixa#id_35361

希望有帮助,

相关问题