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

Getting weighted search #23

Closed
direktornswe opened this issue Nov 26, 2019 · 1 comment
Closed

Getting weighted search #23

direktornswe opened this issue Nov 26, 2019 · 1 comment

Comments

@direktornswe
Copy link

Hi,
I have been playing around with Fuse for a few days now and I can't get weighted search to work. I have a needle array that looks like this:

Array
(
[1] => Array
(
[company] => Array
(
[name] => STARTUPLIFERS IN SWEDEN
[registrationid] => 55XXXX-XXXX
[id] => 1
)
),
[company] => Array
(
[name] => Google
[registrationid] => 55XXXX-XXXX
[id] => 1
),
[tags] => Array
(
[name] => Startup
)
)
......
[7992] => Array
(
[stopwords] => Array
(
[name] => Startup
)
)
...

So essentially an array with companies and I have added "stop words" in the array.

I have created my key array as follows:
'keys' => [
[
'name' => 'stopword.name',
'weight' => 1
],
[
'name' => 'company.name',
'weight' => 0.5
],
[
'name' => 'tags.name',
'weight' => 1
]
]

But when I search for the term "Startup" it does not matter how I weight my keys, the company STARTUPLIFERS is always the one with the lowest score. followed by my stop word that is a 100% match. Im using the other options for my query:
"tokenize" => true,
"matchAllTokens" => true,
"caseSensitive" => false,
"includeScore" => true,
"shouldSort" => true

It looks like this is a limitation perhaps in Fuse.js (Will try to replicate it in JS) as there is no way to force a "word boundary" search that would have helped solving this specific problem.

@loilo
Copy link
Owner

loilo commented Nov 26, 2019

I replicated it in Fuse.js, and it's the exact same behavior. You're correct in that it seems to have to do with exact substring matches not being given a good score.

However, this is a problem that needs to be solved on the Fuse.js side and I encourage you to open an issue there.

It also seems like you're new to GitHub (welcome!) so I'd encourage you to get a little bit familiar with Markdown to format your issues. Especially creating code blocks would be helpful, as your code examples were not easy to read. ❤️

@loilo loilo closed this as completed Nov 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants