-
Notifications
You must be signed in to change notification settings - Fork 22
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
NOT sort by score option #28
Comments
To give context, on MDN Web docs you can fuzzy search the document URIs by starting your autocomplete search with a Try the full Elasticsearch search: https://developer.mozilla.org/en-US/search?q=foreach But our current implementation isn't great and |
Hi @peterbe! Optionally providing a sorter is something that I do have in mind and is already noted here (first point). There are few perf related experiments that I'm doing, after which this task will be picked up.
What issues are you facing with the current implementation? Is it fuzzy matching, less relevant results on searching document URIs, performance or something else? Also, could you please point me to the code where the current fuzzy finding implementation is written? |
It's here: https://github.com/mdn/yari/blob/main/client/src/fuzzy-search.ts
One of them is fast and I use that to reduce down the list of 10,000+ strings down to 1,000 strings. That weeds out the ones that don't even match. Then, the second one is used to get the positions so that I can build the React code for highlighting. My hope is that My very very rough experimentation with switch to |
Yeah, relevance. I'd rather display the "best" document ahead of any that "matches" better. VSCode does something similar and different. |
Funny and timely! I just discovered a bug in our existing code (that doesn't use |
Ok. So I set down to try to figure out what the heck is going on with mdn/yari#4346 and how I can fix it with the existing stack. @ajitid I know it's a big ask but would you be interested in helping to review that. Or at least test it or give it a quick look-over. |
Reviewed it and the code looks fine. From mdn/yari#4347 (comment):
I won't be able to confirm as I haven't tested fzf against fuzzyjs + fuzzysearch though I've seen some initial tests done here. |
That was not a fair comparison for the record. :) By the way, I think contributing a PR to this code base would be very feasible now that I've browsed the code a bit.
|
I'm already working on a branch https://github.com/ajitid/fzf-for-js/tree/feat/skip-score-sorting that will add a boolean |
const fzf = new Fzf(list, {
sort: false
}) |
Thanks @peterbe! While we've merged the (sort) feature, this project still needs contributions in particular areas, most notably performance. Any contribution, either in the form of a PR or a suggestion would be helpful. Cheers! |
@ajitid You're going to hate me for this but, on some basic tests I did, I'm now going to "reverse" my opinion on the default sort function in What happens is if you let the sort be by the documents that have any match, it misses out on those searches where a lot of the characters are together. |
I didn't for you to re-open it. What I meant was that after some more testing it certainly "feels" like it's better to use |
Okay, I'll close it for now then. |
The
find
method always sorts by.score
.What I need is that it doesn't sort at all but leaves the order of the original
list
.So, looking at the Basic usage that example returns:
but what I need it to be is:
because that's the order they appear in the
list
option:The reason for needing this is that my list that I search on are sorted by "popularity".
If the user only type something really short like
f
I really want to favor the popular items first because the assumed likelihood that it's what the user expects to find.So ideal would be something like:
or
so that it only "filters" the list.
The text was updated successfully, but these errors were encountered: