metacat
metacat copied to clipboard
Ampersands (&) in Solr queries cause error
During my discovery of #1575, I noticed that if I include an escaped ampersand (&) in a Solr query, I get an error:
https://dev.nceas.ucsb.edu/knb/d1/mn/v2/query/solr/?wt=json&rows=0&q=%5C%26
<error detailCode="Solr server error" errorCode="500" name="ServiceFailure">
<description>
Error from server at http://localhost:8983/solr/metacat-index: org.apache.solr.search.SyntaxError: Cannot parse '\': Lexical error at line 1, column 2. Encountered: <EOF> after : ""
</description>
</error>
Expected behavior
If an escaped ampersand is included in a query string, it should be treated as the string to search for.
Ampersand is not a special character which needs to be escaped. Double ampersands are. The special characters are:
+ - && || ! ( ) { } [ ] ^ " ~ * ? : /
closing, since this is expected behavior (see Jing's response)
Jing, can you explain why you re-opened this after @artntek closed it so I can understand your reasoning? Thanks.
I verified even if we don't escape or encode the ampersand, we still get error. So I reopened this issue.