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

Fuzzy search results aren't displayed in popularity order #4346

Closed
peterbe opened this issue Jul 28, 2021 · 3 comments · Fixed by #4347
Closed

Fuzzy search results aren't displayed in popularity order #4346

peterbe opened this issue Jul 28, 2021 · 3 comments · Fixed by #4347
Assignees

Comments

@peterbe
Copy link
Contributor

peterbe commented Jul 28, 2021

Go to the search widget and paste in /foreach. That should match every document that has the word foreach in the URI.

We know from Elasticsearch that searching for foreach
displays them in roughly this order:

  1. Array.prototype.forEach()
  2. Map.prototype.forEach()
  3. Set.prototype.forEach()
  4. TypedArray.prototype.forEach()
  5. etc.

they all contain the word foreach in the title so all you have left to rank is the popularity. But it's clearly not working:

Screen Shot 2021-07-28 at 10 07 41 AM

@peterbe
Copy link
Contributor Author

peterbe commented Jul 28, 2021

This is kinda the explanation. When passed in throug the import { match } from "fuzzyjs"; function from fuzzyjs module, it produces those score values that are negative.

I printed them out to try to understand how it filters things:
Screen Shot 2021-07-28 at 10 22 57 AM

Why does /en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach get a score of -32?!
It has to do with the fact that it's long.

I also see lots of new options in the latest version of https://www.npmjs.com/package/fuzzyjs but I don't think we're using that version.

@peterbe
Copy link
Contributor Author

peterbe commented Jul 28, 2021

If you remove the filtering my score > 0 this happens:
Screen Shot 2021-07-28 at 10 32 46 AM

@tannerdolby
Copy link
Contributor

tannerdolby commented Jul 28, 2021

Why does /en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach get a score of -32?! It has to do with the fact that it's long.

Hmm that is quite odd that the score would be negative. But it seems that from the console log output you provided that indeed, the longer the search result the more negative its score is.

And when you remove the filtering score so that they must be > 0 we definitely get some search results that don't make much sense. Now that I've read the conversation in #28 within fzf-for-js, I better understand why we would want a boolean sort property so like mentioned in the corresponding PR, we can better control how the sorting happens to have

Output: lisp, kotlin, elixir

become this with the sorted boolean set to false so we would have the natural sorting that appears in the list array option:

Output: kotlin, elixir, lisp

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

Successfully merging a pull request may close this issue.

2 participants