lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Terence Lai <t...@trekspace.com>
Subject Re: RE: Building query to match a sub-string of a field
Date Tue, 29 Jun 2004 21:52:36 GMT
Hi Ben,

Thanks for your help.

Terence



----------------------------------------------------------
Get your free email account from http://www.trekspace.com
          Your Internet Virtual Desktop!
=========== Original Message ===========
Subject: 
RE: Building query to match a sub-string of a field
From: 
Ben Pryor <BPryor@widen.com>
To: 
Lucene Users List <lucene-user@jakarta.apache.org>
Date: 
Tue Jun 29 17:45:34 EDT 2004
 
If you are building a query using the API, the WildcardQuery class will
allow you to use a leading wildcard character. The QueryParser will not
allow this, however, so if you're getting queries using the QueryParser a
leading wildcard won't work.

I have successfully done substring queries through the API using code
previously posted to the list:
http://www.mail-archive.com/lucene-user@jakarta.apache.org/msg06388.html
I haven't run into any performance problems because of these classes.

There were a few minor changes that needed to be made to that code to make
it work with the latest Lucene 1.4RC3 - I think it was just a matter of
changing a constructor signature.

Ben

-----Original Message-----
From: Terence Lai [mailto:tlai@trekspace.com] 
Sent: Tuesday, June 29, 2004 4:29 PM
To: lucene-user@jakarta.apache.org
Subject: Building query to match a sub-string of a field

Hi Everyone,

I am trying to construct a query which matches a sub-string of a field. As
an illustration, I would like to search the following words by using the
sub-string "test":

- test
- testing
- contest
- contestable

I realize that Lucene does support wildcard searches using "*" and "?" in
the custom query. Therefore, the query string "*test*" should give me the
right result. However, the Lucene query syntax
(http://jakarta.apache.org/lucene/docs/queryparsersyntax.html) does not
allow the wildcard "*" as the first character of the search. Therefore, the
query "*test*" is invalid. Does anyone have a solution to build the query to
achieve the same result?

Thanks,
Terence

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


 

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