I'm using Sunspot Solr search, which works fine for the most part for basic search. It's supposed to be able to handle quotation marks around phrases, so that a search for test case
will return documents with both test and case, whereas a search for "test case"
should return documents with the phrase test case.
However, I've been pulling my hair out over this, because it seems like Rails is stripping out any outer quotation marks from user inputs before it even hits the search engine. Thus "test case"
returns the exact same results as test case
but ""test case""
or "test case"
(with leading and trailing spaces) actually works, in the first case because the outer quotation marks are stripped away leaving the inner ones, and in the second case because this problem only affects leading and trailing quotation marks.
Apparently, this is a known bug and has been marked as won't fix by the Rails team. I'm really surprised how little I can find on this online, since it seems like very common functionality.
How are people getting around this? It doesn't seem like a reasonable solution to me the ask the users to double quote things because of this, and I don't particularly want to go making my own custom modifications to Rack.