lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Otis Gospodnetic <otis_gospodne...@yahoo.com>
Subject Re: How to realize Sql LIKE?
Date Thu, 04 May 2006 15:41:55 GMT
There is also the following, that some guy named Erik contributed recently:

./contrib/regex/src/java/org/apache/regexp/RegexpTunnel.java
./contrib/regex/src/java/org/apache/lucene/search/regex/SpanRegexQuery.java
./contrib/regex/src/java/org/apache/lucene/search/regex/RegexQuery.java
./contrib/regex/src/java/org/apache/lucene/search/regex/JakartaRegexpCapabilities.java
./contrib/regex/src/java/org/apache/lucene/search/regex/JavaUtilRegexCapabilities.java
./contrib/regex/src/java/org/apache/lucene/search/regex/RegexCapabilities.java
./contrib/regex/src/java/org/apache/lucene/search/regex/RegexTermEnum.java
./contrib/regex/src/java/org/apache/lucene/search/regex/RegexQueryCapable.java

As for how to use it, see this:

./contrib/regex/src/test/org/apache/lucene/search/regex/TestSpanRegexQuery.java
./contrib/regex/src/test/org/apache/lucene/search/regex/TestRegexQuery.java

Otis

----- Original Message ----
From: Erik Hatcher <erik@ehatchersolutions.com>
To: java-user@lucene.apache.org
Sent: Thursday, May 4, 2006 6:19:36 AM
Subject: Re: How to realize Sql LIKE?


On May 3, 2006, at 9:39 PM, JustineHMS wrote:
> I m new to Lucene,
>
> Just wondering if there is a way to realize sql 'Like' function in  
> Lucene as
> following:
>
> Select * from user_table where username like '%abc%'
>
> I have checked with wildCardQuery, but it can not start with a '%'.
> What about RegexQuery?  How to use it?

WildcardQuery does support leading wildcard characters, but  
QueryParser is what prohibits it.  A custom QueryParser could be  
created that removes this restriction.  However, the potential of a  
"too many clauses" exception is great with WildcardQuery so you'll  
want to be careful.  Check the list archives for this topic in gory  
and never ending detail :)

    Erik



---------------------------------------------------------------------
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


Mime
View raw message