NCEAS / metacat

Data repository software that helps researchers preserve, share, and discover data
https://knb.ecoinformatics.org/software/metacat
GNU General Public License v2.0
27 stars 13 forks source link

Ampersands (&) in Solr queries cause error #1576

Open laurenwalker opened 2 years ago

laurenwalker commented 2 years ago

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.

taojing2002 commented 2 years ago

Ampersand is not a special character which needs to be escaped. Double ampersands are. The special characters are:

+ - && || ! ( ) { } [ ] ^ " ~ * ? : /
artntek commented 1 year ago

closing, since this is expected behavior (see Jing's response)

mbjones commented 11 months ago

Jing, can you explain why you re-opened this after @artntek closed it so I can understand your reasoning? Thanks.

taojing2002 commented 11 months ago

I verified even if we don't escape or encode the ampersand, we still get error. So I reopened this issue.