Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scoring incorrect when multi word tokens given in different keys #610

Closed
prajavk opened this issue Jan 20, 2022 · 4 comments
Closed

Scoring incorrect when multi word tokens given in different keys #610

prajavk opened this issue Jan 20, 2022 · 4 comments
Labels

Comments

@prajavk
Copy link

prajavk commented Jan 20, 2022

Describe the bug
The scoring logic is not working when using extended search. When multiple words with spaces are given as keys, returning results with shorter string scores are higher.

Version
v6.4.6

  1. I saw an open issue Match all tokens should look in different keys as well. #235 is this fixed in fusejs 6.4.6?
  2. Here I created Js fiddle to reproduce issue with multi words tokens given from different keys. scoring is in correct or results is empty.
    https://jsfiddle.net/prajavk/n79upa8w/22/
  3. Please suggest work around if any for this fiddle

Issue:
fusejs search results order was same when we gave multiple tokens from different keys { title: "drain refill ", tags: ["oil", "flush"] }
For example, "drain oil" will not work when I add token of tags[]. This way, searches as either "drain refill" or "refill drain", would return the expected match.

@renanvalentin
Copy link

I've recently stumble across a similar issue related to word spacing. Word-spacing gets tokenized as

{
 '  ': /*..*/
}

But it fails in case receive \s instead of ' '. My workaround was to replace \s by ' ' and it did the trick:

w.title.replace(/\s/g, ' ')

@prajavk
Copy link
Author

prajavk commented Jan 25, 2022

Team,
where can we apply this wild card setting in fuseJs.
w.title.replace(/\s/g, ' ')
If I have these results to filter using keywords as below
const list = [ { "title": "replace engine oil", "tags": [ "exchange", "R&R", "rpl", "change"] }, { "title": "cabin air filter & engine air filter", "tags": ["dust", "pollen", "air"] }, { "title": "Headlamp / Daytime Running Light Bulb", "tags": [ "lamp","light","headlight","rpl", "R&R"] } ];
For eg: search keywords as
// drain r&r
// headlamp dust
// headlamp R&R
let pattern = "cabin & engine r&r";
fuse.search(pattern);

@Telematica
Copy link

Team, where can we apply this wild card setting in fuseJs. w.title.replace(/\s/g, ' ') If I have these results to filter using keywords as below const list = [ { "title": "replace engine oil", "tags": [ "exchange", "R&R", "rpl", "change"] }, { "title": "cabin air filter & engine air filter", "tags": ["dust", "pollen", "air"] }, { "title": "Headlamp / Daytime Running Light Bulb", "tags": [ "lamp","light","headlight","rpl", "R&R"] } ]; For eg: search keywords as // drain r&r // headlamp dust // headlamp R&R let pattern = "cabin & engine r&r"; fuse.search(pattern);

https://jsfiddle.net/gorn3ks7/

let pattern = "cabin r&r rpl"; let r = pattern.replace(/\s/g, '|'); document.getElementById("code").innerHTML = JSON.stringify(fuse.search(r), null, 2);

@github-actions
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants