Fusejs is not working properly for locations

Viewed 18

I want to search for data,Fusejs returns the wrong result. Suppose I have a location like (Sector-10, Sector-10/1, Sector-10/2, Sector-8) when I type "Sector8"it returns results like ( {Sector-10, Sector-10/1 .....} ). I want a result like if I type "Sector8" it should return" `Sector8" at the beginning. Could someone please help me?

Data

[
  {label:'Sector-10',value:238},
  {label: 'Sector-10/1', value: 1781},
  {label: 'Sector-10/2', value: 141},
  {label: 'Sector-11/4', value: 1780},
  {label:'Sector-8',value:8834}
]

Code

const options = {
 caseSensitive: false ,
  useExtendedSearch: false,
  threshold: 0.9,
  keys: [
    "label",
  ]
};

const fuse = new Fuse(list, options);

// Change the pattern
const pattern = "sector8"

return fuse.search(pattern)
0 Answers
Related