我正在使用spell:suggest查询字典。我假设结果是按距离排序的。但事实并非如此,正如spell:suggest-detailed在下面的示例中所示。
示例:
spell:suggest-detailed("/my-dictionary.xml", "cohn",
<options xmlns="http://marklogic.com/xdmp/spell">
<distance-threshold>10</distance-threshold>
<maximum>3</maximum>
</options>
)结果:
<spell:suggestion original="cohn" dictionary="/my-dictionary.xml" xmlns:spell="http://marklogic.com/xdmp/spell">
<spell:word distance="10" key-distance="0" word-distance="50" levenshtein-distance="1">coin</spell:word>
</spell:suggestion>
<spell:suggestion original="cohn" dictionary="/my-dictionary.xml" xmlns:spell="http://marklogic.com/xdmp/spell">
<spell:word distance="10" key-distance="0" word-distance="50" levenshtein-distance="1">conn</spell:word>
</spell:suggestion>
<spell:suggestion original="cohn" dictionary="/my-dictionary.xml" xmlns:spell="http://marklogic.com/xdmp/spell">
<spell:word distance="9" key-distance="1" word-distance="45" levenshtein-distance="1">crohn</spell:word>
</spell:suggestion>第三个结果的距离是9,小于前两个结果的距离,前两个结果的距离是10,排序是否有误?
发布于 2018-05-07 22:36:53
主要排序关键字是Levenshtein距离,然后是关键字距离,最后是单词距离。
在这里,所有的Levenshtein距离都是1,前两个的关键距离是0,所以这就是为什么它们领先于最后一个。
https://stackoverflow.com/questions/50214317
复制相似问题