You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Scott Smith <ss...@mainstreamdata.com> on 2013/05/19 20:50:42 UTC

classic.QueryParser - bug or new behavior?

I just upgraded from lucene 4.1 to 4.2.1.  We believe we are seeing some different behavior.

I'm using org.apache.lucene.queryparser.classic.QueryParser.  If I pass the string "20110920/EXPIRED" (w/o quotes) to the parser, I get:

org.apache.lucene.queryparser.classic.ParseException: Cannot parse '20110920/EXPIRED': Lexical error at line 1, column 17.  Encountered: <EOF> after : "/EXPIRED"
       at org.apache.lucene.queryparser.classic.QueryParserBase.parse(QueryParserBase.java:131)

We believe this used to work.

I tried googling for this and found something that said I should use QueryParser.escape() on the string before passing it to the parser.  However, that seems to break phrase queries (e.g., "John Smith" - with the quotes; I assume it's escaping the double-quotes and doesn't realize it's a phrase).

Since it is a forward slash, I'm confused why it would need escaping of any of the characters in the string with the "/EXPIRED".

Has anyone seen this?

Scott

Re: classic.QueryParser - bug or new behavior?

Posted by Erik Hatcher <er...@gmail.com>.
Just a thought - this looks like it could be due to the regexp (/pattern/ syntax) support added, but that was added in Lucene 4.0 so it doesn't quite fit that it would be a difference between 4.1 and 4.2.1.  

	Erik

On May 19, 2013, at 14:50 , Scott Smith wrote:

> I just upgraded from lucene 4.1 to 4.2.1.  We believe we are seeing some different behavior.
> 
> I'm using org.apache.lucene.queryparser.classic.QueryParser.  If I pass the string "20110920/EXPIRED" (w/o quotes) to the parser, I get:
> 
> org.apache.lucene.queryparser.classic.ParseException: Cannot parse '20110920/EXPIRED': Lexical error at line 1, column 17.  Encountered: <EOF> after : "/EXPIRED"
>       at org.apache.lucene.queryparser.classic.QueryParserBase.parse(QueryParserBase.java:131)
> 
> We believe this used to work.
> 
> I tried googling for this and found something that said I should use QueryParser.escape() on the string before passing it to the parser.  However, that seems to break phrase queries (e.g., "John Smith" - with the quotes; I assume it's escaping the double-quotes and doesn't realize it's a phrase).
> 
> Since it is a forward slash, I'm confused why it would need escaping of any of the characters in the string with the "/EXPIRED".
> 
> Has anyone seen this?
> 
> Scott


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


RE: classic.QueryParser - bug or new behavior?

Posted by Scott Smith <ss...@mainstreamdata.com>.
We have several versions of lucene running on different systems.  It could be that we didn't notice the problem in 4.1 and it was 3.3 where it seemed to work.

At any rate, I escaped the slash and now all of the unit tests run.  Should have thought to try that myself.  Thanks for the help.

Scott

-----Original Message-----
From: Jack Krupansky [mailto:jack@basetechnology.com] 
Sent: Sunday, May 19, 2013 1:26 PM
To: java-user@lucene.apache.org
Subject: Re: classic.QueryParser - bug or new behavior?

Yeah, just go ahead and escape the slash, either with a backslash or by enclosing the whole term in quotes. Otherwise the slash (even embedded in the middle of a term!) indicates the start of a regex query term.

-- Jack Krupansky

-----Original Message-----
From: Scott Smith
Sent: Sunday, May 19, 2013 2:50 PM
To: java-user@lucene.apache.org
Subject: classic.QueryParser - bug or new behavior?

I just upgraded from lucene 4.1 to 4.2.1.  We believe we are seeing some different behavior.

I'm using org.apache.lucene.queryparser.classic.QueryParser.  If I pass the string "20110920/EXPIRED" (w/o quotes) to the parser, I get:

org.apache.lucene.queryparser.classic.ParseException: Cannot parse
'20110920/EXPIRED': Lexical error at line 1, column 17.  Encountered: <EOF> after : "/EXPIRED"
       at
org.apache.lucene.queryparser.classic.QueryParserBase.parse(QueryParserBase.java:131)

We believe this used to work.

I tried googling for this and found something that said I should use
QueryParser.escape() on the string before passing it to the parser. 
However, that seems to break phrase queries (e.g., "John Smith" - with the quotes; I assume it's escaping the double-quotes and doesn't realize it's a phrase).

Since it is a forward slash, I'm confused why it would need escaping of any of the characters in the string with the "/EXPIRED".

Has anyone seen this?

Scott 


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: classic.QueryParser - bug or new behavior?

Posted by Jack Krupansky <ja...@basetechnology.com>.
Yeah, just go ahead and escape the slash, either with a backslash or by 
enclosing the whole term in quotes. Otherwise the slash (even embedded in 
the middle of a term!) indicates the start of a regex query term.

-- Jack Krupansky

-----Original Message----- 
From: Scott Smith
Sent: Sunday, May 19, 2013 2:50 PM
To: java-user@lucene.apache.org
Subject: classic.QueryParser - bug or new behavior?

I just upgraded from lucene 4.1 to 4.2.1.  We believe we are seeing some 
different behavior.

I'm using org.apache.lucene.queryparser.classic.QueryParser.  If I pass the 
string "20110920/EXPIRED" (w/o quotes) to the parser, I get:

org.apache.lucene.queryparser.classic.ParseException: Cannot parse 
'20110920/EXPIRED': Lexical error at line 1, column 17.  Encountered: <EOF> 
after : "/EXPIRED"
       at 
org.apache.lucene.queryparser.classic.QueryParserBase.parse(QueryParserBase.java:131)

We believe this used to work.

I tried googling for this and found something that said I should use 
QueryParser.escape() on the string before passing it to the parser. 
However, that seems to break phrase queries (e.g., "John Smith" - with the 
quotes; I assume it's escaping the double-quotes and doesn't realize it's a 
phrase).

Since it is a forward slash, I'm confused why it would need escaping of any 
of the characters in the string with the "/EXPIRED".

Has anyone seen this?

Scott 


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org