wouterrutgers / fuzzy-search Goto Github PK
View Code? Open in Web Editor NEWSimple fuzzy search
License: ISC License
Simple fuzzy search
License: ISC License
Whats the browser support on this? I reckon that would be worth having in the docs too as its useful information.
Thanks
Return the best match first
Calculate 'best match' on characters between matches
Hi, I've tried searching for string with say m.a.d. and it will return nothing but the list of options has a string with m.a.d.
Is there a fix to this?
Thanks
I'm using sort: true
I have an example where things aren't sorted as expected
search for 'board'
Results in order (searching these two fields):
'Alarm Dictionary', 'BO_ALARM_DICTIONARY'
'Dogmatix Board Replacements', 'DOGMATIX_BOARD_REPLACEMENT_V'
I would expect the row with "Board" in it to be ordered higher.
But instead, BO_ALARM_DICTIONARY ranks higher, maybe because B O A is close to the beginning of the string?
Whenever I try to import this module into my VueJS / Nuxt Setup I encounter this error: render function or template not defined in component: anonymous
If I comment the import out the page renders normally.
Do you have any workaround?
The output from ts-node REPL after importing the Parser and calling the search routine.
var searcher = new fuzzy_search_1.default(this.registrations, ['name', 'realName', 'email', 'previousEmails', 'regCode'], {
^
TypeError: fuzzy_search_1.default is not a constructor
The actual code is:
searchRegistrations(needle: string) {
const searcher = new FuzzySearch(this.registrations, ['name', 'realName', 'email', 'previousEmails', 'regCode'], {
caseSensitive: false,
});
return searcher.search(needle)
}
I dug around a bit and I can't find anything that I missed... this project looks amazing and was excited to find it. Hope its something simple we missed.
Thanks for the awesome project and the help!
When using the same letter multiple times fuzzy search still returns it as a result.
bbbbbboat would match boat
Also add a test for this issue..
Getting this error when searching on a numeric field:
TypeError: item.toLocaleLowerCase is not a function at Function.isMatch (app.d50f24c….js:3548) at FuzzySearch.search (app.d50f24c….js:3516) at VueComponent.activeData (app.d50f24c….js:3278) at Watcher.get (app.d50f24c….js:35120) at Watcher.evaluate (app.d50f24c….js:35220) at VueComponent.computedGetter [as activeData] (app.d50f24c….js:35446) at Object.get (app.d50f24c….js:34180) at Proxy.render (app.d50f24c….js:32297) at VueComponent.Vue._render (app.d50f24c….js:36241) at VueComponent.updateComponent (app.d50f24c….js:34811)
So i have used fuzzy search to filter array of objects with keys, but i have a nested array of strings in the same object, can i search it?
I think that it would be great if we could highlight characters that triggered the match
search: somestring
result:
foosomestringbar
foosomethingStringbar
API could be something like this
const searcher = new FuzzySearch(people, ['name.firstName', 'state'], {
caseSensitive: true,
highlight: substring => colors.underline.bold(substring)
});
What do you think about such feature? I really miss something like this.
This project to my understanding does two things: Searching object entries based on keys and then matching and scoring their corresponding values.
I've created a library called object-scan, which does solve the first part nicely (there is a lot to it). Would you be interested in a pull request?
When I started I thought object traverse and search was an easy problem. It is not. Hence it might be a good idea not to reinvent the wheel here ;) objext-scan
is a dependency free package (which would fit with fuzzy-search) and has many, many tests.
Let me know what you think! Cheers, L~
Hi,
In my react app the build getting failed with the fuzzy-search.
Failed to minify the code from this file:
./node_modules/fuzzy-search/src/FuzzySearch.js:3:15
It was working previously with the same react-scripts.
Hello, i've noticed you have developed for elobuddy.
I am currently planning to start a new scripting platform and on a developer lookout right now.
Please check out this thread for information regarding this project.
https://www.nulled.to/topic/631617-wanted-skilled-reverse-game-engineers-and-c-devs/
Hi, with typescript 4.1 we can now type path from objects. i.e. generate a string union of path from an object structure.
This would be really helpful to type the array of keypath.
Here is a post on stackoverflow for the same use:
enjoy
It'd be great if it (by default, or with an option) allowed a single search phrase to span multiple keys. For example, with:
[{name: 'The Adventures of Tom Sawyer', author: 'Mark Twain'}]
A search with keys ['name', 'author']
for 'tom mark'
would return no results today, but I'd like for it to return the item in the array as a result.
I'm aware that I can create a compound key, but it'd be great if that were unnecessary. Thanks!
example
[
[ {name: 'alex'}, {name: 'stiven'} ],
[ {name: 'mary'}, {name: 'katy'} ],
...
]
Tests are currently not running on travis. They are tested locally though!
Shall we move babel-plugin-add-module-exports
to devDependencies
?
if title is "Does it support for non sequential word search"
if i search "it support for" it'll return above title
if i search "Does for support" it'll not return
fuzzy-search v2.2.0 is no longer a universal JS:
$ node node_modules/fuzzy-search/dist/FuzzySearch.js
(...)
ReferenceError: window is not defined
As far as I see v2.1.0...v2.2.0 , upgrading build tool versions ( laravel-mix ?) may be related to this issue, I guess.
Is it just me or did this lines somehow didn't make sense.
constructor(haystack = [], keys = [], options = {}) {
if (haystack.length === 0) {
throw new Error('We need an array containing the search list');
}
It looks like that it throws the error when the length of the haystack is 0 .. but the default is an empty Array. Also it can happen that the haystack is empty.
wouldn't it be better this way:
constructor(haystack = [], keys = [], options = {}) {
if (haystack.constructor !== Array) {
throw new Error('We need an array containing the search list');
}
I'm writing a MIME Type dropdown box and using this for fuzzy searching, and the following code demonstrates that the "sort: true" option isn't pulling the best matches to the top:
new FuzzySearch(['application/cdfx+xml', 'application/pdf'], { sort: true }).search('pdf') === 'application/cdfx+xml'
Just to be clear, I would expect application/pdf
to be the first result as it is an exact match
When building for browsers, the default behavior of Webpack when resolving package's main module is to look in package.json
for these fields (in order):
browser
: Browser-targeted module. Good to differentiate from Node targets.module
: Module using ESM syntax (discussion is in progress and stuff might change with Node 14)main
: Module using good-old CommonJShttps://webpack.js.org/configuration/resolve/#resolvemainfields
Also, it's very common to make babel-loader
skip node_modules
dir, to save some build time. Their own example instructs that.
FuzzySearch
correctly points to a valid module
, but that file not only contains ESM syntax, but lots of ES2015+ stuff.
Webpack handles ESM, but the other ES2015+ stuff passes straight through and IE does what it does best.
I suggest you to either:
module
(or create a browser
), with a ES5 module, keeping ESM declarationsForce babel-loader
to run in fuzzy-search
directory;
module: {
rules: [
{
test: /\.js$/,
include: ['src', 'node_modules/fuzzy-search'],
use: ['babel-loader'],
},
],
},
Create an alias, replacing fuzzy-search
with a direct path to dist/FuzzySearch.js
:
resolve: {
alias: {
'fuzzy-search': 'fuzzy-search/dist/FuzzySearch',
},
},
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.