I'm in the process of creating an a search input for restaurants with autocomplete. I was wondering if it would be best for me to require a minimum amount of characters before returning suggested results. One of the main reasons I ask is if a user types in the letter a, then the user will get a maximum of let's say, 10 results with restaurants that start with that particular letter. What would be the best way to approach this?
3 Answers
I was wondering if it would be best for me to require a minimum amount of characters before returning suggested results.
No, don't wait. Very often we don't know correct spelling of strange or unusual names and even second character may be a beat. Imagine one of these two situations:
- You want to have dinner at your favorite French restaurant Le Taureau. You remember sound of its name but is second character a or o or u?
- Your new girlfriend is crazy for Russian food and she told you her favorite restaurant is named Bull alas Телец. She even made spelling then you start typing T then e. Ooops second character is not Latin e but Russian е (Ye). You won't have any match.
What would be the best way to approach this?
When it's technically possible you should order them. If you can get user's location then they can be ordered by distance otherwise by user preferences/history (does he love ethnic food? Asian cuisine?).
Even when it doesn't give the right result your users will feel they have a personalized experience.
Don't forget that typeahead and search results are different things, Your search results shouldn't include only restaurants that starts with typed word but all of them which contains that word (see also Substring search vs Starting letter search). To handle second case (Russian restaurant) well you should also perform some sort of normalization, if not in your typeagead at least in your search results, you may read How can I perform a Unicode aware character by character comparison? for some (maybe) funny technical details.
-
Don't forget that you could always keep an extra field in your database to have the words of all your names written with plain english characters no matter what is the original language. This can be done manually or via an algorithm: stackoverflow.com/questions/1008802/… Nov 22, 2015 at 19:39
-
@george nice idea! Not always applicable (for transliteration, for example, because of multiple possibilities) and harder than what outlined in that post (ligatures, duplicates and so on) and it can't handle errors or character with same appearance but different "meaning" when contrary to "translation". Well in this very specific case I'd do it with a text distance function (if applicable because of performance) Nov 22, 2015 at 20:10
Wait for it ...
The other answers are pointing you in the right direction, but leaving out an important point: Time. Just because the system can be faster than the speed of thought, doesn't mean it should be.
In a very performant system (and shouldn't they all be), you could start returning suggestions that are seemlingly instantaneous. But, you are right to assume that single letter suggestions will often just produce distraction.
If you program in a small delay before returning the first suggestions (I like to start testing around 600ms), most users will be on to the second or third character before anything comes back. You avoid interrupting the average user's train of thought (average being those with more than one character in mind).
For those that really want to get blasted with random suggestions, they'll type a single character and then pause. The slight mental delay while they anticipate suggestions should align with your programmed delay and all will be well.
-
So if I understand what you said correctly you are suggesting to fetch the results on third or next character when the user types fast but also fetch results on first character if user pauses after typing the first character? Nov 22, 2015 at 19:41
-
If I understood him correctly he means always. If typer is in doubt he will pause and see suggestions at 2nd character otherwise later Nov 22, 2015 at 20:13
-
Always have a slight presentation delay. Sometimes a well-engineered system can be too fast. Search suggestions is one of those times. Again, the delay (whether real or programmed) should be slight. Nov 22, 2015 at 21:09
Start it with the first character, imo. You want to immediately show the user what to expect from this.
Think of it like this: I want to type in the name of something, I look at the form, I type a keystroke (or two) and then realize I can't spell it... now I'm off looking it up.
the immediate feedback on the first keystroke is much better. as you said, you should definitely be limiting the list of results.