We've actually been running into this sort of issue a lot, since we take a
user generated query from a web page and then push it into a QueryParser.
In general we've learned that escaping special characters is not enough to
create a well formed query.  Since our users aren't running complicated
queries, we decided instead to completely parse out any non-alphanumerics.
But we still have issues when, for example, someone will search for:

Portland, OR

And Lucene will interpret that "OR" as a special word, rather than "Oregon".
I'm wondering how others are dealing with this type of scenario.  If it'll
help, I can provide more queries that will cause errors similar to the one
below.

Thanks,
Monsur

 

> -----Original Message-----
> From: Matt Magoffin [mailto:[EMAIL PROTECTED] 
> Sent: Friday, August 12, 2005 10:30 AM
> To: java-user@lucene.apache.org
> Subject: QueryParser exception on escaped backslash preceding 
> ) character
> 
> When I try to parse a query with an escaped backslash 
> character like this
> (using Lucene 1.4.3):
> 
> -id:20677 +(addr:Street143 AND zip:\\)
> 
> the QueryParser thows an Exception:
> 
> Encountered "<EOF>" at line 1, column 289.
>                       Was expecting one of: <AND> ... <OR> ...
>                       <NOT> ... "+" ... "-" ... "(" ... ")" 
> ... "^" ...
>                       <QUOTED> ... <TERM> ...
>                       <PREFIXTERM> ... <WILDTERM> ... "[" ...
>                       "{" ... <NUMBER> ...
> 
> However, if I insert a space between the backslash and the 
> parenthesis:
> 
> -id:20677 +(addr:Street143 AND zip:\\ )
> 
> it works. Is this expected behavior or perhaps a bug in the 
> QueryParser?
> 
> -- m@
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to