When searching with ajax based suggesting field, how many letters should be typed before it starts to suggest results? 1,2,3..
If you have another factor that can rank the results (e.g. "popularity", "kuakeli rank"):
- start with the first letter
- limit results by second rank, by picking the TOP N
SELECT TOP 10 FROM Stuff WHERE Name LIKE "x*" ORDER BY Rank)
If you don't have that rank, you could still start after the first letter, but results aren't as useful. Still, there's no usability reason to start with a sorted list:
SELECT TOP 10 FROM Stuff WHERE Name LIKE "x*" ORDER BY Name
Thee are a few traditional reasons for delaying the query:
- Part of your query runs synchronous, and you have to limit UI blocking
- You have to limit traffic / hits to the search provider
This is typically achieved by starting search if no key was pressed for the last few hundred milliseconds, or starting only after a minimum string length.
There's one case left (that I can think of) where starting after the N th key might improve usability: Misleading matches. If your search pool contains elements like this:
SDBXXFDR 1722 Lengthy SDBXXFDR 1723 Still Lengthy ... SDBXXFDR 1799 Short SOBXXFDR 1972 Lengthy with ripples
And you just type "S", the "SD" results may hide the SO one, the chance of pickign the wrong one is rather high. However, that sems very constructed, and I'm not sure if incremental search is a good solution at all if this would be a problem.
An autocomplete functionality is most optimally backed by a structure called a Trie.
Using a trie, you would'nt even have to set a lower limit on characters. Lookup is performed in O(n) where n is length of the query text and is independent (mostly) of the number of search items that are in your database.
Please take a look at a node.js based trie implementation that I did - MyTriePOC.
From a user experience perspective, if you are really setting a lower limit, best practice is to provide a tooltip to instruct the user to keep typing more characters for best results.