0

我正在尝试使用 fuse.js 搜索一些数据,但它似乎忽略了我的密钥并搜索了整个项目。

我用这样的数据数组解析一个 json 文件。它似乎可以在任何地方找到单词,甚至是嵌套键“desc”。

[
   {
        "name": "Kael",
        "rarity": "rare",
        "stage": "early",
        "title": "Early Game Kael Build 1",
        "author": "3030030003",
        "data": [
            {
                "label": "Masteries",
                "desc": "Some text.",
                "image": "https://linktosomeimage.com/image.jpg"
            },
            {
                "label": "Stats and equipment",
                "desc": "More text",
                "image": "https://linktosomeimage.com/image.jpg"
            }
        ]
    },
{
        "name": "Other character",
        "rarity": "rare",
        "stage": "early",
        "title": "Some title",
        "author": "3030030003",
        "data": [
            {
                "label": "Masteries",
                "desc": "Some text with Kael in it.",
                "image": "https://linktosomeimage.com/image.jpg"
            },
            {
                "label": "Stats and equipment",
                "desc": "More text",
                "image": "https://linktosomeimage.com/image.jpg"
            }
        ]
    }
]
const fuzzy = new Fuse(guides, {
            keys: ['name']
        });
const result = fuzzy.search('kael');

它返回预期的数据,但也返回我没有给出的键中的搜索词项,在这个愚蠢的示例中,我会得到这两个项目作为结果。如果需要,我可以提供更多信息。

谢谢,

4

0 回答 0