You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Karl Koch <Th...@gmx.net> on 2005/08/17 19:50:14 UTC

[Lucene 1.2] Boolean OR on all query terms

Hello experts,

I have the following code:

Query query = QueryParser.parse(queryString, searchFields[0], analyser);
Hits hits = searcher.search(query);

and the following code for search across multiple fields:

Query query = MultiFieldQueryParser.parse(queryString, searchFields,
analyser);
hits = searcher.search(query);

I have some questions. 

The query string in my application is of in a very simple format. Basically
a number of words are separated by spaces (e.g. "dog cat"). No additional
orperators (e.g. "+", OR, AND, etc. shall be used). But, I wand that all of
these terms are "OR"ed by default to maximise recall (the amount of
results). How can I do that with Lucene 1.2? (I am running the search engine
on a PDA which does not allow me to go beyong version 1.2. In the Lucene
Book I have found parser. I have found the setOperator(int operator) method
which however works only from Lucene 1.3 onwards. Can sombod help me out? 

If somebody knows how to make Lucene 1.3 run with Java 1.2.2, I am also
happy to hear about :-).

Kind Regards,
Karl

-- 
Lust, ein paar Euro nebenbei zu verdienen? Ohne Kosten, ohne Risiko!
Satte Provisionen f�r GMX Partner: http://www.gmx.net/de/go/partner

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


Re: [Lucene 1.2] Boolean OR on all query terms

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Aug 17, 2005, at 1:50 PM, Karl Koch wrote:
>

> Hello experts,
>
> I have the following code:
>
> Query query = QueryParser.parse(queryString, searchFields[0],  
> analyser);
> Hits hits = searcher.search(query);
>
> and the following code for search across multiple fields:
>
> Query query = MultiFieldQueryParser.parse(queryString, searchFields,
> analyser);
> hits = searcher.search(query);
>
> I have some questions.
>
> The query string in my application is of in a very simple format.  
> Basically
> a number of words are separated by spaces (e.g. "dog cat"). No  
> additional
> orperators (e.g. "+", OR, AND, etc. shall be used). But, I wand  
> that all of
> these terms are "OR"ed by default to maximise recall (the amount of
> results). How can I do that with Lucene 1.2? (I am running the  
> search engine
> on a PDA which does not allow me to go beyong version 1.2. In the  
> Lucene
> Book I have found parser. I have found the setOperator(int  
> operator) method
> which however works only from Lucene 1.3 onwards. Can sombod help  
> me out?

Given your description, you don't need a query parser at all.  Simply  
tokenize the field at whitespace boundaries (you could use an  
analyzer to do this if you like, or simply StringTokenizer).  Then  
build a BooleanQuery with nested TermQuery's all unrequired which  
will give the OR nature.

     Erik



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