lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <e...@ehatchersolutions.com>
Subject Re: Query Question
Date Fri, 18 Feb 2005 02:05:36 GMT
On Feb 17, 2005, at 5:51 PM, Luke Shannon wrote:
> My manager is now totally stuck about being able to query data with * 
> in it.

He's gonna have to wait a bit longer, you've got a slightly tricky 
situation on your hands....

> WildcardQuery(new Term("name", "*home\**"));

The \* is the problem.  WildcardQuery doesn't deal with escaping like 
you're trying.  Your query is essentially this now:

	home\*

Where backslash has no special meaning at all... you're literally 
looking for all terms that start with home followed by a backslash.  
Two asterisks at the end really collapse into a single one logically.

> Any theories as to why the it would not match:
>
> Document (relevant fields):
> Keyword<type:203>
> Keyword<name:marcipan + home*>
>
> Is the \ escaping both * characters?

So, again, no escaping is being done here.  You're a bit stuck in this 
situation because * (and ?) are special to WildcardQuery, and it does 
no escaping.  Two options I think of:

	- Build your own clone of WildcardQuery that does escaping - or 
perhaps change the wildcard characters to something you do not index 
and use those instead.

	- Replace asterisks in the terms indexed with some other non-wildcard 
character, then replace it on your queries as appropriate.

Erik


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


Mime
View raw message