在我的 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>
这似乎与range
或collection
约束不同,建议开箱即用,无需suggestion-source
.
对于单词
约束不显示建议是否有原因,例如表现?此行为是否记录在某处?
使用 MarkLogic 9.0-8。
最佳答案
如果您为特定 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
希望有帮助,
关于marklogic - 没有字数限制的建议,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54200837/