Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fuse.js: Exact name match

I am trying to implement an exact name match on a database.

Is there a way to get only "Smith", and not "Smithee", "Smithers", "Smithe" etc? Setting the Distance and Threshold to 0 do not do it. I can of course go through the results once they have appeared and take out the unwanted values, but it would be more efficient to do it in one take.

like image 627
Tyler330 Avatar asked Oct 22 '25 23:10

Tyler330


1 Answers

(Hopefully you're on the latest version of Fuse.js)

If your data looks like something like this:

const list = [{ name: 'Smith' } /*, etc...*/]

You could use extended search:

const fuse = new Fuse(list, {
  keys: ['name'],
  useExtendedSearch: true
})

// Search for items that exactly match "smith"
fuse.search('=smith')
like image 155
krisk Avatar answered Oct 24 '25 16:10

krisk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!