A tiny, efficient, fuzzy search that doesn't suck

Overview

▒ μFuzzy

A tiny, efficient, fuzzy search that doesn't suck


Introduction

This is my fuzzy 🐈 . There are many like it, but this one is mine.

uFuzzy is a fuzzy search lib designed to match a relatively short search string (needle) against a large list of short-to-medium strings (haystack). It might be best described as a more forgiving String.prototype.indexOf().

Common use cases are list filtering, auto-complete/suggest, title/name or description search, filenames or functions. uFuzzy is case insensitive and expects all alpha-numeric characters in the needle to occur in the same order, with an adjustable tolerance for additionally inserted characters; horse cart will not match cart horse, but would be matched for either cart or horse. This disqualifies uFuzzy from being used as a spellcheck (due to omitted letters), or a fulltext/document search, where terms can be out of order. However, it's easy to perform a separate uFuzzy search for each permutation of terms in the needle to achieve out-of-order matching without appreciable degredation in performance for most cases.

Now that you know what uFuzzy isn't, let's see what it can offer over existing solutions.

Comments
  • Is it possible to search through a list of objects?

    Is it possible to search through a list of objects?

    One of the big reasons why I use Fuse is that I can pass a list of objects and it will search on a subset of keys. This requires additional indexing, I assume. Is it possible to do this with uFuzzy? It seems to only accept string[]

    question 
    opened by christopher-caldwell 5
  • Ignore a part of the needle?

    Ignore a part of the needle?

    Hello, thank you for your library, I'm about to switch from Fuse.js!

    I just found a use case that can be problematic for some search logic : in a needle with many part, and many part matches results, but if one part only doesn't match, the result is entirely excluded.

    Example with needle super mario 64 and options intraMode: 1, intraSub: 1, intraTrn: 1, intraDel: 1, intraIns: 1 on this data set : https://leeoniya.github.io/uFuzzy/demos/compare.html?libs=uFuzzy&intraIns=1&intraMode=1&search=super%20mario%2064

    I think all "super mario" results should appear, but it doesn't pass the filter function at all.

    Is there a configuration that can handle this use case that I missed? Thank's!

    question 
    opened by Freddy03h 3
  • Add a changelog

    Add a changelog

    Hi, thanks for this lib, it's working great. Would be gret if you could add changelog with each version. You could maybe generate from your commits.

    Thanks in advance!

    opened by urbany 3
  • Question re mixed alpha and numeric needles

    Question re mixed alpha and numeric needles

    I have option interLeft set to 2 (strict) so searching starts at beginning of needles/words.

    An example UK post codes (think ZIP code) is CW3 5BQ. uFuzzy treats 'CW3' as 2 needles 'CW' and '3'. It fails to find the complete postcode string 'CW3 5BQ 'and also fails to find '5bq'.

    Is there any option to stop splitting mixed alpha and numric words into multiple needles

    Test string:

    [
      "Line with UK postcodes. A typical UK post code is CW3 5BQ. Some numbers 3 5 53 and 7. Some letters C, w, wW, W, WC and CW.  I should be able to match CW3 but not CW5 and I should be able to match 5BQ "
    ]
    

    test_UK_postcodes

    question 
    opened by HamptonNorth 3
  • How to tweak handling of spaces?

    How to tweak handling of spaces?

    Hi, your library looks awesome! Kudos to you.

    I was trying the demo, but I couldn't find a way to tell uFuzzy to include results that contain spaces in between the search query. I want to get results like "Super Markup Man" or "Super Mario" when querying for "superma" (just remove the space between super and ma in the example query).

    image

    Is this possible?

    question 
    opened by tomas 3
  • Polyfill prototype.at

    Polyfill prototype.at

    In my case, I using uFuzzy in React Native (Android)

    When we search the long char, we got errors like:

    p.at is not a function. (In 'p.at(-1)', 'p.at' is undefined)
    

    I'm not sure this is a good idea to add polyfill something like

    if (!String.prototype.at) {
      String.prototype.at = function (n) {
        // ToInteger() abstract op
        n = Math.trunc(n) || 0;
        // Allow negative indexing from the end
        if (n < 0) n += this.length;
        // OOB access is guaranteed to return undefined
        if (n < 0 || n >= this.length) return undefined;
        // Otherwise, this is just normal property access
        return this[n];
      };
    }
    

    Any suggestion? thanks.

    opened by l2aelba 2
  • Highlighting search results

    Highlighting search results

    Recent commit says "make uFuzzy.highlight() generic so it can also return e.g. array of DOM or JSX nodes"

    Have working search but cannot see how to use uFuzzy.highlight - any hints/sample usage/docs?

    Thanks for your work. Fast and does everyting I need

    question 
    opened by HamptonNorth 2
  • Question about the example in the README

    Question about the example in the README

    hi, I replicated the example from the readme to test it with some custom data and I think there's a mistake in it. At the end of the example it logs the data from the haystack using i directly:

    // render pre-filtered but unordered matches
    for (let i = 0; i < idxs.length; i++) {
      console.log(haystack[i]);
    }
    

    Shouldn't this use idxs[i] to reference the matches?

    for (let i = 0; i < idxs.length; i++) {
      console.log(haystack[idxs[i]]);
    }
    

    Thank you!

    opened by nicolaibach 1
  • Unsupport Chinese charactor

    Unsupport Chinese charactor

    uFuzzy is perfect in English context, but it doesn't give the correct result when datasource contain Chinese charactors.

    some samples here:

    const list = ['测试数据', 'input autofocus - Google 搜索']
    const result = ufuzzy.filter(list, '搜')
    
    opened by RickysPapa 1
Releases(0.9.0)
Owner
Leon Sorokin
"All problems in computer science can be solved by another level of abstraction ...except for the problem of too many levels of abstraction."
Leon Sorokin
A personal semantic search engine capable of surfacing relevant bookmarks, journal entries, notes, blogs, contacts, and more, built on an efficient document embedding algorithm and Monocle's personal search index.

Revery ?? Revery is a semantic search engine that operates on my Monocle search index. While Revery lets me search through the same database of tens o

Linus Lee 215 Dec 30, 2022
An efficient (and the fastest!) way to search the web privately using Brave Search Engine

Brave Search An efficient (and the fastest) way to search the web privately using Brave Search Engine. Not affiliated with Brave Search. Tested on Chr

Jishan Shaikh 7 Jun 2, 2022
Suck a DAG out of a peer in the IPFS network.

dagula Suck a DAG out of a peer in the IPFS network. Install npm i dagula Usage import { Dagula } from 'dagula' import { getLibp2p } from 'dagula/p2p

Alan Shaw 11 Nov 2, 2022
"Jira Search Helper" is a project to search more detail view and support highlight than original jira search

Jira Search Helper What is Jira Search Helper? "Jira Search Helper" is a project to search more detail view and support highlight than original jira s

null 41 Dec 23, 2022
Tesodev-search-app - Personal Search App with React-Hooks

Tesodev-search-app Personal Search App with React-Hooks View on Heroku : [https://tesodev-staff-search-app.herokuapp.com/] Instructions Clone this rep

Rahmi Köse 1 Nov 10, 2022
Instant spotlight like search and actions in your browser with Sugu Search.

Sugu Search Instant spotlight like search and actions in your browser with Sugu Search. Developed by Drew Hutton Grab it today for Firefox and Chrome

Drew Hutton (Yoroshi) 9 Oct 12, 2022
🍭 search-buddy ultra lightweight javascript plugin that can help you create instant search and/or facilitate navigation between pages.

?? search-buddy search-buddy is an open‑source ultra lightweight javascript plugin (* <1kb). It can help you create instant search and/or facilitate n

Michael 4 Jun 16, 2022
Node starter kit for semantic-search. Uses Mighty Inference Server with Qdrant vector search.

Mighty Starter This project provides a complete and working semantic search application, using Mighty Inference Server, Qdrant Vector Search, and an e

MAX.IO LLC 8 Oct 18, 2022
Allows users to quickly search highlighted items on Wikipedia. Inspired by the "search Wikipedia" function on the kindle mobile app.

wikipedia-search Allows users to quickly search highlighted items on Wikipedia. Inspired by the "search Wikipedia" function on the kindle mobile app.

Laith Alayassa 18 Aug 15, 2022
A plugin for Obsidian (https://obsidian.md) that adds a button to its search view for copying the Obsidian search URL.

Copy Search URL This plugin adds a button to Obsidian's search view. Clicking it will copy the Obsidian URL for the current search to the clipboard. T

Carlo Zottmann 6 Dec 26, 2022
🟢 Music player app with a modern homepage, fully-fledged music player, search, lyrics, song exploration features, search, popular music around you, worldwide top charts, and much more.

Music-player-app see the project here. 1. Key Features 2. Technologies I've used Key Features: ?? Fully responsive clean UI. ?? Entirely mobile respo

suraj ✨ 3 Nov 16, 2022
Tiny and powerful JavaScript full-text search engine for browser and Node

MiniSearch MiniSearch is a tiny but powerful in-memory fulltext search engine written in JavaScript. It is respectful of resources, and it can comfort

Luca Ongaro 2k Jan 3, 2023
A tiny search engine.

nanosearch A tiny search engine. Suitable for in-browser use, this provides n-gram based search results. Quickstart import { SearchEngine } from '@toa

Daniel Lindsley 10 Aug 24, 2022
A tiny search engine.

nanosearch A tiny search engine. Suitable for in-browser use, this provides n-gram based search results. Quickstart import { SearchEngine } from '@toa

Daniel Lindsley 10 Aug 24, 2022
Gas-efficient on-chain batched shuffling for NFTs

Batch NFT reveal This repository contains a gas-efficient implementation of an on-chain shuffling algorithm used to reveal NFTs in batches. The main b

Tubby Cats 97 Dec 12, 2022
A set of tools, helping you building efficient apps in a fast way. >> SvelteKit & GraphQL <<

KitQL KitQL, A set of tools, helping you building efficient apps in a fast way. ?? Infos Documentation: https://kitql.vercel.app/ Day by day progress,

JYC 262 Dec 27, 2022
Grayce Muthui 8 Jun 16, 2022
A minimalistic yet efficient way to stringify and revive instances via JSON.

json-instances Social Media Photo by Francisco J. Villena on Unsplash A minimalistic yet efficient way to stringify and revive instances via JSON. If

Andrea Giammarchi 11 Jun 23, 2022
An efficient drop-in replacement for JSON.

JCOF: JSON-like Compact Object Format A more efficient way to represent JSON-style objects. Status This format isn't nailed down yet. Most changes wil

Martin Dørum 147 Nov 26, 2022