documentcloud/visualsearch — pull request #71 by dgiunta (2012-08-02 14:48:39+00:00)
Title: Normalizing input for comparisons against category

Seeing as how a user can input mixed case for the category, and the search bar will autocomplete regardless, it's possible for the facets to also be categorized by the mixed case that was entered by the user.

As such, when you try to do something like vs.searchQuery.withoutCategory('something'), you may not end up filtering out the actual category you're looking for, because the user may have entered it initially as "Something".

This is kinda confusing to describe. Let's try step-by-step instead:

1. You have a visual search box setup with a facet named "Blah".
2. A user enters "bl" in the search box, and the facet autocomplete appears showing "Blah".
3. The user selects "Blah" from the list, adding that facet to the search.
4. Then when you programmatically run something like the following: `vs.searchBox.value()' that will return something like: `"blah: 'what the user entered'"`. Note the lowercase "b" in "blah".
5. So, if you were then to do something like: `vs.searchQuery.withoutCategory('Blah')`, the result would still contain the user's entered `"blah: 'what the user entered'"`.

This is because the filtering mechanism in search_query.js does not normalize the input. In my pull request, I've chosen to normalize to lower case, as I'm guessing that's the more common way users are entering stuff.

Thanks,
Dave Giunta