加权搜索选项在Fuse.js中是否正常工作?

时间:2018-06-14 10:57:31

标签: fuse.js

我在一个项目中使用Fuse.js并试图让一些行为正常工作,我发现Fuse给出的结果令人困惑。

作为参考我正在使用这些选项来初始化Fuse:

includeMatches: true,
shouldSort: true,
includeScore: true,
threshold: 0.2,
distance: 100,
maxPatternLength: 32,
minMatchCharLength: 1,
keys: [
  { name: 'name', weight: 1 },
  { name: 'description', weight: 0.25 },
  { name: 'tags', weight: 0.1 },
  { name: 'other', weight: 0.05 },
]

当我在寻找“亚洲人”时,我得到了这些结果:

Nice Restaurant by the Sea
Score: 0.00095 
Matched by:
tags -> Asian

Sweet Lao Restaurant
Score: 0.00095 
Matched by:
tags -> Asian

Oriental Cuisine
Score: 0.00095 
Matched by:
description -> Maybe the best Asian restaurant in the world!
tags -> Asian

Sushi Asian Fusion Grill
Score: 0.00095 
Matched by:
name -> Sushi Asian Fusion Grill
tags -> Asian

现在根据我的理解,当我将“名称”键的重量设置为1(最大值)时,我希望它首先与 Sushi Asian Fusion Grill 匹配,或者将其排名高于其他人因为名字应该是得分的较高影响者,但看起来它给所有人的分数基本相同,无论它是否只与标签或名称和标签相匹配。

这是预期的行为吗?我怎样才能这样做,如果它在名称中找到它,它会将它排名更高?

由于

0 个答案:

没有答案