Im using http://fusejs.io/ to search some json data. The data is big list of cabinets that each contain n number of items.
Data example:
{"cabinets":[
{"cabinet":"A4","items":[
{"title":"Toys","keywords":"leksaker, pingpong, kendama, pingis","id":"98"},
{"title":"Skisch Grand Prix","keywords":"Pokal, cup, pris, skisch","id":"99"},{"title":"Lamp prototype","keywords":"lamp-prototyp","id":"100"}]},
{"cabinet":"B4","items":[
{"title":"Screens (LCD)","keywords":"skärm display","id":"30"},
{"title":"Displays","keywords":"screen skärm","id":"31"},
{"title":"Lampor","keywords":"","id":"32"}]}
...
The search looks at the title and the keywords of an items, I want it to return the id of the matched item.
.then(function (response) {
$scope.cabinets = response.data.cabinets;
var options = {
shouldSort: false,
threshold: 0.3,
location: 0,
distance: 100,
maxPatternLength: 32,
minMatchCharLength: 2,
keys: ["items.title","items.keywords"],
id: "items.id"
};
fuse = new Fuse($scope.cabinets, options);
});
Problem is that when I search for "Displays", it returns the ID for "Screens (LCD" which is the first item of the cabinet. Same thing happens if I search for "Lampor".
This is not the specified behavior according to: http://fusejs.io/#searching-by-id
Can anyone spot my error?