[#1570] User search improvements via Levenshtein distance calculation
Closes #1570 (closed)
Experimental feature to improve search results for short queries, especially containing typos.
Should make it much easier to find @hj on any Pleroma instance. :)
The approach still uses similarity()
for searching in user names / nicknames but also applies rank bonus for short queries (currently: @levenshtein_max_query_length 5
) in case Levenshtein distance to local-format nickname (domain stripped) is from 0 to 2 (it feels to make sense to allow 0 typos for 1-char queries, 1 typos for 2- and 3-char queries, and 2 typos for longer queries — this may very well need future tuning, though). The rank bonus is non-linear, see trigram_levenshtein_rank/_
(2 typos should give a small bonus, no typos should boost the rank highly).