lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ari Miller <ari1...@gmail.com>
Subject Issues with escaping special characters
Date Thu, 14 May 2009 23:18:18 GMT
Say I have a book title, literally:

(Parenth+eses

How would I do a search to find exactly that book title, given the presence
of the ( and + ?  QueryParser.escape isn't working.
I would expect to be able to search for (Parenth+eses  [exact match] or
(Parenth+e  [partial match]
I can use QueryParser.escape to escape out the user search term, but feeding
that to QueryParser with a StandardAnalyzer doesn't return what I would
expect.

For example, (Parenth+eses --> QueryParser.escape --> \(Parenth\+eses, when
parsed becomes:
PhraseQuery:
    Term:parenth
    Term:eses

Note that the escaped special characters seem to be turned into spaces, not
used literally.
Up to this point, even attempting to directly create an appropriate query
(PrefixQuery, PhraseQuery, TermQuery, etc.), I've been unable to come up
with a query that will match the text with special characters and only that
text.
My longer term goal is to be able to take a user search term, identify it as
a literal term (nothing inside should be treated as lucene special
characters), and do a PrefixQuery with that literal term.

In case it matters, the field I'm searching on is indexed, tokenized, and
stored.

Potentially relevant existing JIRA issues:
http://issues.apache.org/jira/browse/LUCENE-271
http://issues.apache.org/jira/browse/LUCENE-588

Thanks,
Ari

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message