# TypeAhead with multiple sources problems

So I have a search box which allows you to search for people by first name or three other identifiers.

The search box is limited to show only 12 responses maximum. Which when divided by 4 categories is a simple 3 from each. 3,3,3,3

If for example one of the categories of the search threw up no results I can display four of each. And so on and so on. 4,0,4,4. 6,0,0,6, 12,0,0,0

Problem A occurs when the category set returns less than the required 3, but not zero. In this case what would one show? 3,1,3,3? Or would the user expect us to be clever and attempt 4,1,4,3.

Problem B occurs with the limit in general. What if the result sets return more? For example I search John, 13 Johns are found and the particular John the user is looking for just happens to be 13 (don’t forget limited to 12, I can increase limit but where do you draw the line?)

So my questions first and foremost are their any simple solutions to this anyone can think of? Failing that what alternatives to typeahead can be used?

I was thinking perhaps an entry on the bottom, “click to see more” but would love to hear other suggestions.

Typeahead is effective in providing suggestions or functioning as a "quick search", but if your search is sufficiently complex (which it sounds like it is), then I think you need to provide a way to view all results (paginated or dynamically loaded, if necessary).

I wouldn't worry too much about it being "balanced" all the time. Take a look at Pandora's typeahead:

They do several things well:

1. Isolate the "Top Hit" to draw your eye to the most likely thing you were looking for.
2. Group results by result category, but limit the number of each so you can browse through the categories without scrolling forever.
3. Provide a way to view all results for a particular result category.
4. Provide a way to view all results, regardless of result category.
5. Dynamically evaluate how many results per category to return based on specific results.

Additionally, it's obvious that they have a lot of server-side smarts to try and generate this result set to be as useful and effective as possible. In this example, I am sure there are other "Track" results that match the query provided, but they limit that to 1 in this case, however, searching "hallelu" returns almost exclusively Track results.

I don't think your solutions has to be as sophisticated as this, but I think if you take some pointers from them, you could find solutions to several of your issues.

• Absolutely perfect. It covers the idea I had about “see all”. Caters for more or less results. Obviously the server side smarts will take some work but far less than trying to cater for all eventualities. I like it! Thanks a lot. Feb 12, 2018 at 23:24
• Now, this is getting into implementation details, but if you'd like a way to automatically determine how many items of each category to show, I'd probably do something like: Find total number of results for each category (e.g. 14 artists, 24 tracks, 6 stations). Calculate percent of total result set for each category (31% artists, 55% tracks, 13% stations). Use this distribution to determine how many to show within your designated number of results, showing at minimum 1 result, if it exists—in your case, multiply by 12 (4 artists, 6 tracks, 2 stations). Feb 13, 2018 at 14:27
• Doing that, you'd be able to automatically show more tracks for "hallelu" and more artists with "the ro", as in these examples. Feb 13, 2018 at 14:28
• I did think this but surely under this circumstance larger datasets would cut values out? 1000,500,1000,50000 would prioritise category 4 heavily? Feb 13, 2018 at 14:34
• It would, but I'd say that'd be okay. Google does this with their results—searching "restaurants" places "Maps" as the second category (behind "All"), whereas "men's suit" shows "Shopping" next. Your example's corresponding percentages are [2%, 1%, 2%, 95%]. Multiplying each by 12 (and rounding up to show at least 1 result of each) would return [1, 1, 1, 9]. It'd be your call whether or not this is a reasonable distribution, but I'd be comfortable with that, as a user. This would still provide me a "handle" to be able to select "Show all {category 2 results}" while favoring the "hot" category. Feb 13, 2018 at 15:00