When searching a list, should the search return items starting with the search term or should it return items containing the search term?

For Example

Given a list of Camera Brands and a search box. When typing "c" does the search return with all words starting with "c" or does it search for words with "c" in it?

Ideally I would like the list to show "Canon" at the top when the user enters "can".

  • 2
    What exactly are you asking? First it looks like you are asking a question, but then it looks like you are giving your opinion in the last sentence. Commented Feb 14, 2011 at 16:20
  • Your example is very clearly searching. Filtering would imply you actually have a exclusion criteria; some also consider sorting a sort of filtering. Either way, unless you give us "your definition" I'm sure a lot of people will just see it as "them red apples Vs them green apples."
    – srcspider
    Commented Feb 18, 2011 at 8:40

5 Answers 5


You can have it both ways by having all words that contain "c", but display the words that begin with "c" at the top.

  • that. Ranks could be refined further, e.g. title vs. body matches, title starts with vs. words starts with vs. word contains.
    – peterchen
    Commented Feb 15, 2011 at 9:44

I think you may be mixing up two unrelated issues here. Searching vs. Filtering is one, and "begins with" vs. "contains" is another.

The difference between searching and filtering is basically whether you do it on the fly, or do you execute the search only once the user gave an explicit command to do so - pressed "search" or "go" or whatever. Granted, Google complicated things a bit with their instant search, and I consider it as search pretending to be filtering :). Judging from your example, it seems like you really are talking about filtering.

As to "begins with" vs. "contains": when you search across a number of fields at once, or in a large set of data, or when the fields may contain expressions and not just single words, I'd say go with "contains".

For example, you are searching your music collection, across the fields of Artist, Genre, Album, Artist, in thousands of files, and you want to locate "The Wall". You won't like to have to type "The", because half the songs, albums and bands begin with that. You just want to type "Wall" and end up with maybe 10 results. Or, you're searching the phone book in your phone, for John Smith. You don't want to have to remember whether he's listed as John Smith or as Smith, John. You just want to type "Smith" and find him.

But your example is different. There's a very small set of inflexible brand names, so I know just what I want to find, and I don't want anything to get in the way. So if I type N, I expect to find Nikon, and definitely not Sony or Minolta.

In short, only in a few very specific cases would I use "contains" on the letter-level. Maybe in linguistic settings such as an online dictionary. But I would definitely use it to search for expressions containing specific words - and the words would still need to begin with the letters that I type, not just contain them.


There are a bunch of different ways you could go with this. If you were to copy Google, however, you wouldn't use a wildcard search like you're suggesting. Google searches for alternate versions of a root word using a sophisticated full-text indexing. This has benefits both in speed and in accuracy. Then they have their "did you mean..." mechanism which is truly excellent.

You can't recreate something as good as Google very easily. However, full-text indexing is available for most SQL implementations. It's even built into the free Microsoft SQL Server Express. There are also some good open-source projects like Lucene (available for Apache) that offer this sort of functionality.

If you wanted to combine full-text search with a wildcard search, and your servers can handle the load, then you can certainly do that. The idea would be to show the full-text search results sorted by relevance, and then append any additional wildcard search results at the end of that. This is the solution I've come up with for one of my sites.


The main goal is for your audience to find whatever they are looking for quickly. The auto suggest is only one way to achieve this.
The user probably expects the search box to suggest words with whatever they have typed "in" it as they may not know the exact product name (e.g. typing "EOS" to get Canon cameras). For more detailed search options you should offer a "Detailed Search", where your customers can specify things like: exact wording, excluding, beginning/ending etc.

Also make sure to have a look at faceted search/navigation patterns:



Take a look at Endeca's Auto-suggest design pattern:

Auto-suggest offers search term suggestions while the user types into a search box

In particular:

Invoke the auto-suggest panel only after a minimum of three characters has been entered.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.