fts_solr does not quote lucene's special characters

Michael Stilkerich ms at mike2k.de
Sun Nov 1 17:03:36 UTC 2015


Hello,

   I am using Dovecot 2.2.19 with the solr backend for full text search 
and experience the following issue.

When I issue a search that includes characters that are part of lucene's 
query syntax (e.g. the double quote character), dovecot does not escape 
the special characters and issues a request with invalid syntax to the 
solr server.

For example, I search for foo"bar, then my IMAP client (roundcube) sends 
the following to dovecot:

A0003 UID THREAD REFS US-ASCII ALL UNDELETED BODY "foo\"bar"

Dovecot in turn uses the following request URI to query SOLR:

"GET 
/solr/select?fl=uid,score&rows=113739&sort=uid+asc&q=body:%22foo%22bar%22&fq=%2Bbox:4d86808c56d44282b35cea8700dda537+%2Buser:%22myuser%22 
HTTP/1.1" 400 994

Solr responds with error 400 and the following body:
type Status report
message null
description The request sent by the client was syntactically incorrect.

This is because the " character in foo"bar is not quoted in the solr 
request. When I adapt the request to quote the " character solr succeeds 
with the expected result:

"GET 
/solr/select?fl=uid,score&rows=113739&sort=uid+asc&q=body:%22foo%5C%22bar%22&fq=%2Bbox:4d86808c56d44282b35cea8700dda537+%2Buser:%22myuser%22 
HTTP/1.1" 200 535

A fix for this would be highly appreciated.

Cheers,
   Michael



More information about the dovecot mailing list