jeancroy / FuzzySearch

:mag: Fast autocomplete suggestion engine using approximate string matching
MIT License
194 stars 32 forks source link

give higher ranking to full words? #20

Open eliteproxy7 opened 5 years ago

eliteproxy7 commented 5 years ago

i have these items to search through

when I search "sea" the results are in this order

I would like to give full words that are in the query that match higher ranking is this possible?

here are my configurations

  output_limit: 6,
  output_map: 'alias',
  source: this.items,
  thresh_include: 8,
  minimum_match: 1,
  bonus_token_order: 10,
  bonus_match_start: 10,
  bonus_position_decay: 0,
  highlight_bridge_gap: 2,
  highlight_prefix: true,
  thresh_relative_to_best: 0.5
jeancroy commented 5 years ago

So, it's something I haven't done in this library but it make sens so I can probably do it.

When a full word is match, the part that I call prefix will span the full target and the full query token. So m=n=prefix.

I'll note for myself https://github.com/jeancroy/FuzzySearch/blob/master/src/score.js#L62 https://github.com/jeancroy/FuzzySearch/blob/master/src/score.js#L187

In the meantime increasing bonus_match_start or decreasing bonus_token_order may help. (The token order bonus penalize word later in the sentence.)