AFAIR Solr already provide an utility methods in org.apache.solr.client.solrj.util.ClientUtils#escapeQueryChars, we use it in the default implementation of SolrUtils we have in platform, see: https://github.com/xwiki/xwiki-platform/blob/stable-15.10.x/xwiki-platform-core/xwiki-platform-search/xwiki-platform-search-solr/xwiki-platform-search-solr-api/src/main/java/org/xwiki/search/solr/internal/DefaultSolrUtils.java#L522 so we probably need to expose it in a script service. |