Search "-" in websolr
websolr returns
RSolr::Error::Http - 400 Bad Request
Error: <html><head><title>Apache Tomcat/6.0.28 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 400 - org.apache.lucene.queryParser.ParseException: Cannot parse '----': Encountered " "-" "- "" at line 1, column 1.
Was expecting one of:
"(" ...
"*" ...
<QUOTED> ...
<TERM> ...
<PREFIXTERM> ...
<WILDTERM> ...
"[" ...
"{" ...
<NUMBER> ...
ever tried to find the "-" character.
other special characters work just fine like ":" etc. I tried using CGI.escape but couldn't escape these characters.
source to share
Have you tried to escape with a backslash?
Usually, when you index your documents, the tokenizer removes the hatch characters on its own, so you may need to just remove the dash anyway if you don't want it to be a negative query.
The complete Solr query syntax is here: http://wiki.apache.org/solr/SolrQuerySyntax
source to share
As Chris correctly points out, you need to escape the backslash.
Depending on which search parser you are using, there are special characters that make sense. Starting with this post, the Lucene query parser (and therefore Solr) assigns special meaning to these characters:
+ - && || ! ( ) { } [ ] ^ " ~ * ? : \
You should refer to the docs for Lucene Query Syntax Syntax for their full meaning. The Solr Query Parser offers a superset of the Lucene parser syntax by default, as described in the SolrQueryParser wiki page .
If you don't want to worry about escaping things, the DisMax Query Parser is designed to accept input that is closer to what the user can type into the search box. I haven't tested various specials against it recently, but generally, it is probably more graceful in the input it takes.
source to share