You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Brian Whitman <br...@echonest.com> on 2009/02/24 02:22:34 UTC

arcane queryParser parseException

server:/solr/select?q=field:"''anything can go here;" --> Lexical error,
encountered <EOF> after : "\"\'\'anything can go here"
server:/solr/select?q=field:"'anything' anything can go here;" --> Same
problem

server:/solr/select?q=field:"'anything' anything can go here\;" --> No
problem (but ClientUtils's escape does not escape semicolons.)

server:/solr/select?q=field:"anything can go here;" --> no problem

server:/solr/select?q=field:"''anything can go here" --> no problem

As far as I can tell, two apostrophes, then a semicolon causes the lexical
error. There can be text within the apostrophes. If you leave out the
semicolon it's ok. But you can keep the semicolon if you remove the two
apostrophes.

This is on trunk solr.

Re: arcane queryParser parseException

Posted by Chris Hostetter <ho...@fucit.org>.
: > Hmmmm.... good call, i didn't realize the escape method had been so
: > blanket in 1.3.  this way we protect people who were using it in 1.3 and
: > relied on it to protect them from the legacy ";" behavior.

: Thanks hoss and ryan. That explains why the error was new to us-- we
: upgraded to trunk from 1.3 release and this exception came from a solrj
: processed query that used to work.

I would still suggest you (and everybody else) always specify "sort" and 
"defType" params anyway (even if just as defaults in your requestHandler 
declaration), just to be very clear and complete about what you expect 
(and to ensure this weird legacy behavior doesn't burn you if clients who 
*aren't* using SolrJ (or ClientUtils) query your port.


-Hoss


Re: arcane queryParser parseException

Posted by Brian Whitman <br...@echonest.com>.
>
> : I went ahead and added it since it does not hurt anything to escape more
> : things -- it just makes the final string ugly.
>
> : In 1.3 the escape method covered everything:
>
> Hmmmm.... good call, i didn't realize the escape method had been so
> blanket in 1.3.  this way we protect people who were using it in 1.3 and
> relied on it to protect them from the legacy ";" behavior.



Thanks hoss and ryan. That explains why the error was new to us-- we
upgraded to trunk from 1.3 release and this exception came from a solrj
processed query that used to work.

Re: arcane queryParser parseException

Posted by Chris Hostetter <ho...@fucit.org>.
: I went ahead and added it since it does not hurt anything to escape more
: things -- it just makes the final string ugly.

: In 1.3 the escape method covered everything:

Hmmmm.... good call, i didn't realize the escape method had been so 
blanket in 1.3.  this way we protect people who were using it in 1.3 and 
relied on it to protect them from the legacy ";" behavior.

-Hoss


Re: arcane queryParser parseException

Posted by Ryan McKinley <ry...@gmail.com>.
On Feb 23, 2009, at 9:13 PM, Chris Hostetter wrote:

>
> : server:/solr/select?q=field:"'anything' anything can go here\;" -- 
> > No
> : problem (but ClientUtils's escape does not escape semicolons.)
>
> ClientUtils doesn't escape it because it's not a special character  
> in the
> SolrQueryParser.
>

I went ahead and added it since it does not hurt anything to escape  
more things -- it just makes the final string ugly.

In 1.3 the escape method covered everything:

http://svn.apache.org/repos/asf/lucene/solr/tags/release-1.3.0/client/java/solrj/src/org/apache/solr/client/solrj/util/ClientUtils.java

  public static String escapeQueryChars( String input )
   {
     Matcher matcher = escapePattern.matcher( input );
     return matcher.replaceAll( "\\\\$1" );
   }



Re: arcane queryParser parseException

Posted by Chris Hostetter <ho...@fucit.org>.
: server:/solr/select?q=field:"'anything' anything can go here\;" --> No
: problem (but ClientUtils's escape does not escape semicolons.)

ClientUtils doesn't escape it because it's not a special character in the 
SolrQueryParser.

it *is* a special character to the OldLuceneQParserPlugin if (and only if) 
there is no "sort" param specified (this is all due to legacy behavior)

Try either of these...

  ?defType=lucene&q=%22%27%27anything+can+go+here;%22
  ?sort=score+desc&q=%22%27%27anything+can+go+here;%22

(we should probably change the default QParser to "lucene" and document in 
the upgrade notes how legacy users of the ";" sort sequence can get the
old behavior by setting defType=lucenePlusSort as an invariant param. ... 
anyone want to submit a patch?)

-Hoss