code: def _escape_solr_query(query, field="title"):
          
          # Different rules for "title" and "identifier" fields :/
          if field == "title":
              replacement = r"\\\\\1"
          else:
              replacement = r"\\\1"
  
          return re.sub(r'([\'" +\-!\(\)\{\}\[\]^"~?:\\/]|&&|\|\|)', replacement, query)
docs: Escapes special characters in Solr queries.
          Note that this omits * - this is intentionally permitted in user queries.
          The list of special characters is located at http://lucene.apache.org/core/4_0_0/queryparser/org/apache/lucene/queryparser/classic/package-summary.html#Escaping_Special_Characters