trie-search
trie-search copied to clipboard
Add 'ranking' reducer based on depth and count of matches
If typing in spot rock
, the TrieSearch.RANK_REDUCER
will sort the results like:
0: 'spot rock' // exact word match, correct order
1: 'spotify rocks' // incomplete word match, correct order
2: 'rock spot' // exact match, incorrect order, no word gap
3: 'spot the rocks' // exact word match, correct order, with gap word(s)
4: 'rock the spot' // exact word matches, incorrect order, with gap word(s)
Need to give this more thought, but this would definitely be a nice ranking style feature for reducing the found results. Downside is sorting, but if this can done inline with the array concatenations this might actually mean that it just dictates the order in which the arrays are concatenated when done which is a much faster operation than sorting all the items at the end.