Allow the abilty to specify search options (e.g. startsWith or contains) #97

ryanhaugh opened this Issue Jul 28, 2011 · 11 comments


None yet
9 participants

Right now the search feature only uses 'contains' logic, meaning the results will include all items that have the specified text anywhere in the text. It would be nice if we could change the functionality to only include items that start with the specified text.

For example, if I type in 'es' I would see 'United States' among the results. It would be nice if I could changed it so I would only see 'Estonia'


pfiller commented Jul 28, 2011

At the moment, search only shows "starts with" and "es" should not match United States. I don't think searches based on contain are particularly useful. If someone is searching for "es" they probably mean to match Estonia and not United States, Bangladesh, United Arab Emirates, etc.

@pfiller pfiller closed this Jul 28, 2011

I guess I should have tested my example...a better example is 'St' matching 'United States'. It would be nice if we could choose whether we select items where any word starts with the specified text or the first word starts with it.

Leksat commented Aug 25, 2011

What about the described option?
Currently I need a 'contains' logic. Why you don't want to add the option?

I want this as well.

I have a drop down with:

Member Id : Name


1234 : Alistair
5678 : Bob

It is important for them to be able to view and search on the ID, but in most cases they will be searching against the name.

Another vote to re-open this issue from me.

I'd really like to specify "contains" searching, for example

Search: "Analyst"

  • Analyst
  • Business Analyst
  • Systems Analyst

pfiller commented Sep 22, 2011

@AlistairB and @philBrown Both of the search cases you describe should work in Chosen today as the search regex matches from the start of each word.

Two things have been asked for in this thread that Chosen does not do:

  1. Match only from the start of the string: In this request, a search for "St" would not match "United States"
  2. Match text within a string: "ate" matches "United States"

pzgz commented Jan 15, 2012

This feature is actually very useful for none english users, for example, in Chinese, normally, we do need to change the input method for input Chinese characters, normally, we might include some latin chars in the utf-8 strings, so that user can type the latin chars directly to make a quick search, instead of switch the input method before the next step. I think providing an extra option will be very useful. Thanks.

JamoCA commented Jan 17, 2012

I got excited about Chosen because I really liked the simple UI, but it lacked the ability to select anything unless you knew the exact start of a word. This may work for simple/known entries like states or countries, but not when using an unfamiliar list containing street names, mixed category/products, client/project or pre-entered phone number values.

I started using the "Searchable DropDown" plugin and it offers quite a bit of customization that I wish was available in Chosen (however it's limited to a single selected item):

There are options for:

  • Exact match
  • Wildcard character support (* = any char, ? = one char)
  • Ignore case sensitivity

Another plugin I use is AutoSuggest. It's UI is similar, but it searches subtext, highlights the search text and adds the ability to create new values on-the-fly. It can also perform an ajax request to retrieve json list from web server. (This is critical when it's impractical to include a large list of possible values inline.)

akuma commented Jun 27, 2012

Hi, @pfiller , this feature is very useful for Asian Languages, e.g. Chinese. So why not support it? :)

akuma commented Jun 27, 2012

Sorry. I found this feature is already supported in v0.9.8.
Just use like this:

$(".chzn-select").chosen({"search_contains": true});

I am unable to search with starting letters of a word. Please help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment