Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Fuzzy Search in JavaScript

  • Last Updated : 05 Nov, 2020

Fuzzy searching matches the meaning, not necessarily the precise wording or specified phrases. It performs something the same as full-text search against data to see likely misspellings and approximate string matching. it’s a very powerful tool that takes into consideration the context of the phrase you wish to look.

Fuzzy Search is additionally called as approximate string matching. It’s powerful because often text data is messy. For instance, shorthand and abbreviated text are common in various sorts of data. Additionally, outputs from OCR or voice to text conversions tend to be messy or imperfect. Thus, we want to make the foremost of our data by extrapolating the maximum amount of information as possible.

Hey geek! The constant emerging technologies in the world of web development always keeps the excitement for this subject through the roof. But before you tackle the big projects, we suggest you start by learning the basics. Kickstart your web development journey by learning JS concepts with our JavaScript Course. Now at it's lowest price ever!

Fuzzy search is more powerful than exact searching when used for research and investigation. Fuzzy search is very useful when researching unfamiliar, foreign-language, or sophisticated terms, the correct spellings of which don’t seem to be widely known. Fuzzy search can also be used to locate individuals supported incomplete or partially inaccurate identifying information.

Installing the package:



$ npm install --save fuse.js

Example:

Javascript




const Fuse = require('fuse.js')
 
const people = [
    {
        name: "John",
        city: "New York"
    },
    {
        name: "Steve",
        city: "Seattle"
    },
    {
        name: "Bill",
        city: "Omaha"
    }
]
 
const fuse = new Fuse(people, {
    keys: ['name', 'city']
})
 
// Search
const result = fuse.search('jon')
 
console.log(result)

Output:

[ { item: { name: 'John', city: 'New York' }, refIndex: 0 } ]

Some common fuzzy search libraries for JavaScript are:

  • List.js : https://listjs.com/
  • Fuse.js : https://fusejs.io/
  • Fuzzy-search :https://www.npmjs.com/package/fuzzy-search
My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!