farzher / fuzzysort

Fast SublimeText-like fuzzy search for JavaScript.

Home Page:https://rawgit.com/farzher/fuzzysort/master/test/test.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

different kind of search

halukkaramete opened this issue · comments

How would you pass your options so that matches with single red letters across words are weighed significantly down?

For example, when I search for

"intentions rewards"

I get this on top.

ConcernINg thE variety of words used by Narrators conveyIng different significatiONS regarding the concept of narrating and Which ...

As you see hitting 1 letters across words does not seem to make sense.

But if I were to do search this:

"rewards intentions"

What is said REgarding the statement: ''The reWARD of deeds dependS upon the INTENTION and hoping to get rewards ...

Here more words are bolded as full words... and matches are not all that scattered. I think spotting the entire word "INTENTION" as red and bolded in the search results or "REWARD" for that matter, is a more practically successful search that the individual letters are matching across words that are far from one another, like this RiuoiuoiuiouoEeouiouououioWeouiouououioAeouiouououioReouiouououioD
Of course, the word order being searched also matters here.

To make it more practical, is it possible pass certain options to your algorithm, where the higher ranking results are based on the following criteria

  1. word order should not make much difference ( so "intentions rewards" vs "rewards intentions" should not alter the results dramatically )

  2. the entries with 1 or 2 single letter matched words are regarded only very little. but entries with more word-to-word matches are regarded the highest. For example, entries that have the full word "reward" or "intention" are ranked much higher than those entries where plenty of individual letters of "r" "e" "w" "a" "r" ... etc are found.

maybe you want a different search library. fuzzysort is better as a lookup than a search. ie you already know what you're looking for and want to get to it with few keystrokes. your example data doesn't look like a good fit.

1. word order should not make much difference ( so "intentions rewards" vs "rewards intentions" should not alter the results dramatically )

discussion here #58

2. the entries with 1 or 2 single letter matched words are regarded only very little. but entries with more word-to-word matches are regarded the highest. For example, entries that have the full word "reward" or "intention" are ranked much higher than those entries where plenty of individual letters of "r" "e" "w" "a" "r" ... etc are found.

simply filter out results that you don't like, and/or overwrite the score with your own then resort them. most similar issue here #87 (comment)

fixed in v2.0.0