Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use word boundary matching #1465

Closed
wants to merge 2 commits into from

Conversation

koenpunt
Copy link
Collaborator

@harvesthq/chosen-developers This fixes #75 (which has been around for 2 years already..), #1463 and actually also #1216, because the provided solution over there won't work.

By making use of word boundary matching (http://www.regular-expressions.info/wordboundaries.html) the split word search is much cleaner (no more actual splitting of strings), and the search results are better.

Example:
There is a Chosen select box with the option 'Heard Island and Mcdonald Islands' (like on the example page). With enable_split_word_search set to true (default) searching for 'and Mc' won't show any results. Although searching for 'and' and 'Mcdonald' does.

With my modifications the results will show as expected.

@pfiller
Copy link
Contributor

pfiller commented Aug 16, 2013

Wow, this is great. I've been testing it and testing it and I think it works great. That being said, it's a pretty significant change to the way searches are performed in Chosen so I want to tread lightly.

I really want to make sure we've got this locked down before we totally +1 it. Obviously, @kenearly and @stof should weigh in (though I think the latter is on vacation).

  • Copy this to a branch of Chosen and open a PR from there
  • Add unit tests for verifying that search results are correct. To do this, we might need to break the actual search match function out of the winnow method.
  • Performance Test with 1000s of items (perhaps replacing test + match with a single match call)
  • Determine if we need to make an API change related to enable_split_word_search or search_contains. I don't think you should be able to turn off enable_split_word_search if search_contains is true, but I want to do some experimenting there.

This is really is pretty awesome. Thanks @koenpunt.

@pfiller pfiller mentioned this pull request Aug 16, 2013
3 tasks
@pfiller
Copy link
Contributor

pfiller commented Aug 16, 2013

Ok, #1483 is now the place for discussion and feedback. Any code changes for that branch should be done via a PR just as you would to master.

@pfiller pfiller closed this Aug 16, 2013
@crh3675
Copy link

crh3675 commented Jul 25, 2014

I am rather unsure of how to patch my current (0.9.1) version of Chosen for this without having to compile Coffescript. Is there a Javascript patch that I could apply?

@harvesthq harvesthq locked and limited conversation to collaborators Jul 25, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Search bug
3 participants