法术:建议错误的命令?

And*_*s H 1 marklogic

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>
)
Run Code Online (Sandbox Code Playgroud)

结果:

<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>
Run Code Online (Sandbox Code Playgroud)

第三个结果的距离是9,小于距离为10的前两个结果的距离.排序中是否有错误?

小智 5

主要排序键是Levenshtein距离,然后是键距离,然后是单词距离.

这里所有人的Levenshtein距离都是1,前两个的关键距离是0,所以这就是他们在最后一个之前的原因.