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: syntax of queries.
Date Sat, 20 Dec 2003 00:09:55 GMT
On Friday, December 19, 2003, at 05:42  PM, Ernesto De Santis wrote:
> I have news questions:
>
>  - apiQuery.add(new TermQuery(new Term("contents", "dot")), false, 
> true);
>
> new Term("contents", "dot")
>
> The Term class, work for only one word?

Careful with terminology here.  It works for only one "term".  What is 
a term?  That all depends on what happened during analysis.  Generally 
speaking, though, "word" is the right generalization for a "term" - but 
we have to be careful technically speaking.

> new Term("contents", "dot java")
> for search for dor OR java in contents.

Wrong.  When constructing a query through the API, if you want an OR 
you'd need to add two TermQuery's to a BooleanQuery, one for each 
"word" and make them not required.

> My problem is that the user, entry a phrase, and i search for any word 
> in a
> phrase. No the entire phrase.
> I need parse de string?, take word for word and add a TermQuery for 
> each
> word?

Yes.

If you have a text string of multiple terms you want added to a boolean 
query you could do so programatically by analyzing the string as I do 
in my article in AnalyzerDemo or by parsing it through some other 
mechanism than QueryParser and add each as a TermQuery.  You're on 
track!

	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