lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eric Isakson" <Eric.Isak...@sas.com>
Subject RE: Keyword search with space and wildcard
Date Tue, 02 Sep 2003 15:43:27 GMT
Not sure about documented examples, but I often find the unit tests (in src/test of lucene's
CVS) to be very useful  for examples but I didn't see any for what you are looking for.

Basically, query parser builds up a vector of BooleanClause objects then loops over those
on a BooleanQuery object calling add(BooleanClause). I agree JavaCC isn't really simple to
follow, but there is a lot of plain java in there that does the parts you are interested in
and if you build the .java file and ignore the token parsing stuff, you can look at in your
favorite java IDE.

What you can do is cast the query you get from QueryParser to a BooleanQuery (that is the
only type of Query that QueryParser will return) then create your WildcardQuery or any other
queries you need that you didn't get in the query string and add them as clauses to the BooleanQuery
using add(Query query, boolean required, boolean prohibited).

I don't know how query combine works (never used it), but the javadoc comment leads me to
believe it is not what you are looking for and a bit of poking around in the sources gives
me the same impression.

Eric 

-----Original Message-----
From: Brian Campbell [mailto:becampbel@hotmail.com] 
Sent: Tuesday, September 02, 2003 11:05 AM
To: lucene-user@jakarta.apache.org
Subject: Re: Keyword search with space and wildcard


Great.  Is there an example anywhere on how I might be able to build such a 
Query?  QueryParser isn't really all that simple since it's built with 
JavaCC.

What might be ideal for me is if I can continue to use the highlevel 
interface to build the main query (ie use it to parse my query string and 
return me some kind of Query - BooleanQuery, TermQuery, etc) and then build 
a WildcardQuery by hand and "combine" the two together?  For example, is it 
as simple as calling Query.combine() to combine the two?  Is there a better 
way?  Is there a documented example like this?  Thanks!

-Brian




>
>This can be done, AFAIK.
>
>This is one thing that many people seem unaware of: you don't HAVE to 
>use QueryParser to build queries. In your case it seems like you should 
>be able to construct query you want if you either by-pass QueryParser, 
>or create a dummy analyzer (one that does no tokenization but returns 
>all input as one token).
>

_________________________________________________________________
Enter for your chance to IM with Bon Jovi, Seal, Bow Wow, or Mary J Blige 
using MSN Messenger http://entertainment.msn.com/imastar


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