我想对具有平面层次结构的对象执行模糊搜索。在 Fuse.js 的演示页面上,您必须指定要在对象中查找的键。不幸的是,我没有特定的标识符。
Fuse.js 演示:
var books = [{
title: "Old Man's War",
author: {
firstName: "John",
lastName: "Scalzi"
}
}];
var fuse = new Fuse(books, { keys: ["title", "author.firstName"] });
我的设置:
const data = {
"100": "https://assets-cdn.github.com/images/icons/emoji/unicode/1f4af.png?v6",
"1234": "https://assets-cdn.github.com/images/icons/emoji/unicode/1f522.png?v6",
"+1": "https://assets-cdn.github.com/images/icons/emoji/unicode/1f44d.png?v6",
"-1": "https://assets-cdn.github.com/images/icons/emoji/unicode/1f44e.png?v6"
};
const fuse = new Fuse(data, { keys: ??? });
fuse.search('+1'); // should return "https://assets-cdn.github.com/images/icons/emoji/unicode/1f44d.png?v6",