lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erick Erickson <erickerick...@gmail.com>
Subject Re: Am I correctly parsing the strings ? Terms or Phrases ?
Date Tue, 22 Mar 2011 13:27:59 GMT
A good habit to develop is to print out the toString() of the assembled
queries, that'll get you going pretty quickly understanding what the
query assembly is all about without having to wait for people to respond.

But the short form is that phrase queries require all the terms to be
adjacent, which may be what you want but may not.

BooleanQuery is just asking for all the terms. You should probably
normalize them.

Parsing is something like
Query query = QueryParser.parse("your text here");
and the returned query is what you pass to the searcher. This latter
will apply the analysis chains to your input and is probably perferred.

Best
Erick

On Tue, Mar 22, 2011 at 3:41 AM, Patrick Diviacco
<patrick.diviacco@gmail.com> wrote:
> OK, so I'm currently doing this:
>
> booleanQuery.add(new QueryParser(org.apache.lucene.util.Version.LUCENE_40,
> "tags", new
> WhitespaceAnalyzer(org.apache.lucene.util.Version.LUCENE_40)).parse(phrase[i]);
>  , BooleanClause.Occur.SHOULD);
>
> I just want to add single terms to my booleanQuery. if I pass a query to the
> add method, am I considering the single terms ?
>
> thanks
>
>
>
> On 21 March 2011 22:15, Ahmet Arslan <iorixxx@yahoo.com> wrote:
>
>> > Date: Monday, March 21, 2011, 7:39 PM
>> > One more thing: It is actually not
>> > clear to me how to use PhraseQuery... I
>> > thought I can just pass a phrase to it, but I see only
>> > add(Term) method...
>> > should I parse the string by myself to single terms ?
>>
>> Yes, you need to do it.
>>
>> QueryParser transforms String into Query.
>>
>>
>> http://lucene.apache.org/java/2_9_3/api/core/org/apache/lucene/queryParser/QueryParser.html
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> 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