Search does not return expected results.
Only one object returned
All items returned
^6.4.3"
No - Never used before
1) npm install --save fuse.js
2) copy and paste code below
3) run
macOS: 10.15.7 (19H15)
import Fuse from 'fuse.js';
const list = [
{
auditLog: "logs-1/.asjdfnjasbfa.json",
author: 'John Scalzi',
tags: ['fiction']
},
{
auditLog: "logs-2/.ahjdfnjasbfa.json",
author: 'Steve',
tags: ['thriller']
}
]
const options = {
// Search in author and in tags array
keys: ['auditLog']
}
const fuse = new Fuse(list, options)
const result = fuse.search("logs-1")
console.log(result)
I'm seeing all items returned:
[
{
item: {
auditLog: 'logs-1/.asjdfnjasbfa.json',
author: 'John Scalzi',
tags: [ 'fiction' ]
},
refIndex: 0
},
{
item: {
auditLog: 'logs-2/.ahjdfnjasbfa.json',
author: 'Steve',
tags: [ 'thriller' ]
},
refIndex: 1
}
]
Fuse version: 6.4.3
@krisk I would think that only one item would be returned for a match on "logs-1"?
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days
bump
This is working as expected. If the search criteria is "logs-1", it will match both "logs-1" and "logs-2". Remember that Fuse is doing an approximate string matching (aka, fuzzy matching), and while "logs-1" is a perfect match, "logs-2" is a very close match nonetheless.
What would be the best way to get fuse to return only an exact match if there is one, likewise only return the partial matches if it can't find an exact?
Anyone find a good config? I want to make something like the fuzzy finder in vscode - if I am looking for a file called log-1 with the query log-1, I do not want log-2 in my search results.
Most helpful comment
This is working as expected. If the search criteria is "logs-1", it will match both "logs-1" and "logs-2". Remember that Fuse is doing an approximate string matching (aka, fuzzy matching), and while "logs-1" is a perfect match, "logs-2" is a very close match nonetheless.