olivernn / lunr.js

A bit like Solr, but much smaller and not as bright
http://lunrjs.com
MIT License
8.89k stars 548 forks source link

When using fuzzy matching (editDistance), inexact matches have equal score to exact matches #383

Open asazernik opened 5 years ago

asazernik commented 5 years ago

e.g. with editDistance of 3 and query of "beans", both "beans" and "bran" match with the same score. Search relevance decaying with edit distance would make this feature much more useful.

I have tested this on 2.3.5.

olivernn commented 5 years ago

I think it is possible to achieve something similar combining boosts and edit distance, e.g increasing the edit distance reduces the amount of boost:

foo~1^100 foo~2^10 foo~3^1

In the current implementation the edit distance and wildcards just allow you to match more terms, they don't have any impact by themselves on how relevant those terms are to your query.

A cool feature (or even plugin) would be to provide just a term, say "beans", and a query with the right boosts and wildcards/edit distance applied that would give reasonable results. The current search and query methods are a little lower level than that.

KVannimmen commented 3 years ago

I'm having the same issue when searching on a firstName field: For "Lissah" both "Lissa" and "Lissah" have the same score and for some reason the exact match is not the first option.