On Aug 15, 2005, at 3:05 PM, Monsur Hossain wrote:
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.

If you're ripping out non-alphanumerics, you may as well simply create the Query through the API instead of using QueryParser. I do this for all the structured search options on the Rossetti Archive search page: http://www.rossettiarchive.org/rose/

I analyze (or string tokenize) the text for a field, and then build a Query from it rather than allowing QueryParser expression syntax. QueryParser is probably overkill for most applications needs anyway, and can end up getting in the way in the cases described in this thread.

    Erik


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]



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

Reply via email to