2

我正在尝试使用 Fuse JS 对字符串列表进行模糊搜索,但它返回的结果没有意义。我在这里设置了一个播放代码作为示例。

这是我的清单

[
   "Yoga with Adriene - Revolution",
   "Brewdog beers",
   "NBA teams seen live",
   "Yoga with Adriene - DEDICATE - 30 days",
   "Yoga with Adriene - home",
]

我的代码配置是

const options = {
  isCaseSensitive: false,
  includeScore: true,
  shouldSort: true,
};

当我使用搜索词“yoga home”进行搜索时,返回的最接近的匹配项是“Brewdog beers”,这显然是最差的搜索结果,我希望它首先返回“Yoga with Adriene - home”结果并匹配 2 个单词。结果是:

[
  {
    "item": "Brewdog beers",
    "refIndex": 1,
    "score": 0.6932183529538054
  },
  {
    "item": "Yoga with Adriene - Revolution",
    "refIndex": 0,
    "score": 0.6959441913889373
  },
  {
    "item": "Yoga with Adriene - home",
    "refIndex": 4,
    "score": 0.6959441913889373
  },
  {
    "item": "Yoga with Adriene - DEDICATE - 30 days",
    "refIndex": 3,
    "score": 0.7504597227725356
  }
]

其中 0 分表示完全匹配。

4

0 回答 0