Quotation marks need to be escaped in Solr facet queries #17

ksclarke opened this Issue Apr 18, 2012 · 5 comments


None yet
3 participants

Current facet link produces something like 39_s:"Smythe,%20William%20"Bill"" (when the thing being faceted has quotes in it).

It should be encoded to something like 39_s:"Smythe,%20William%20%5C"Bill%5C"" (where the quotes are escaped by a backslash).

The first will return zero hits while the second will return the correct number of hits.

waynegraham was assigned Apr 19, 2012

Oops, think I commented in the wrong place; posting here too:

This did not fix the problem. The " needs to be escaped for Solr as " -- this is different from html encoding

See http://lucene.apache.org/core/3_6_0/queryparsersyntax.html#Escaping%20Special%20Characters for more details

Also, the isset() replaced the !empty() -- there are cases where $current['facet'] is empty but set. isset() breaks but !empty() catches both cases.

Oh, sorry... see the isset() !empty() issue is filed on another ticket (which is still open)

waynegraham reopened this Apr 21, 2012


waynegraham commented Apr 21, 2012

Need to test to see if mysql_real_escape_string has side effects for this; otherwise a quick preg_replace should work...


waynegraham commented Apr 24, 2012

Looking a bit more, Apache_Solr_Service::escape() may be what is needed.

erochest closed this in a99366b Apr 25, 2012


erochest commented Apr 25, 2012

Apache_Solr_Service::escape seemed to introduce extra back-slashes. I may track this down later.

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