> can i escape all possible operators with a requesthandler?

With a custom one yes. You can use the static method 
org.apache.lucene.queryParser.QueryParser.escape(String s). 
 
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) 
throws Exception, ParseException, InstantiationException, 
IllegalAccessException 
{

 String q = req.getParams().get(CommonParams.Q);
 ModifiableSolrParams solrParams = new   ModifiableSolrParams(req.getParams());
 solrParams.set(CommonParams.Q, QueryParser.escape(q));
 req.setParams(solrParams);
 super.handleRequestBody(req, rsp);
}

With this solution users cannot use solr query syntax anymore. For example 
range, wildcard queries won't work.

> or can i escape these operators automatic when the syntax
> is wrong ?

May be you can try to parse value of q parameter with new QueryParser in try 
catch block. If exception occurs you can escape special characters.
However I would prefer to do it in client side.


      

Reply via email to