Search code examples
djangosolrsunburnt

Escape colon in a Scorched/Sunburnt/Solr search


I'm using scorched for interfacing my Django code with my Solr instance:

response = si.query(DismaxString(querydict.get('q')).execute()

In the data I'm searching I have colons (e.g. Col: Mackay's Reel) and I don't want Solr to interpret that colon as a 'field' query:

   "metadata":[
      "error-class","org.apache.solr.common.SolrException",
      "root-error-class","org.apache.solr.common.SolrException"],
    "msg":"undefined field Col"

How can I escape all the colons the user enters in the query?

I'm getting an error even on the Solr query interface directly.


Solution

  • For now my workaround is by adding a backslash to each colon via JavaScript before sending the form, so that the colons are sent as ':'.