lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bourne71 <gary...@live.com>
Subject Re: Generating Query
Date Thu, 13 Aug 2009 02:11:18 GMT

thanks for the suggestion, but unfortunately it does not work ><


Ahmet Arslan wrote:
> 
>> I am trying to build a query that looks like the
>> following:
>> url:(+news +politics)^1.5 content:(+news +politics)^2.0
>> 
>> But I can't seems to find any reference to it. I try
>> hardcoding it like the
>> following:
>> BooleanQuery query = new BooleanQuery();
>> query.add(new TermQuery(new Term(field, "+news
>> +politics")),
>> BooleanClause.Occur.SHOULD);
> 
> Query t1 = new TermQuery(new Term("url", "news"));
> Query t2 = new TermQuery(new Term("url", "politics"));
> 
> Query t3 = new TermQuery(new Term("content", "news"));
> Query t4 = new TermQuery(new Term("content", "politics"));
> 
> BooleanQuery b1 = new BooleanQuery();
> b1.add(t1, BooleanClause.Occur.MUST);
> b1.add(t2, BooleanClause.Occur.MUST);
> b1.setBoost(1.5f);
> 
> BooleanQuery b2 = new BooleanQuery();
> b2.add(t3, BooleanClause.Occur.MUST);
> b2.add(t4, BooleanClause.Occur.MUST);
> b2.setBoost(2.0f);
>         
> BooleanQuery finalQuery = new BooleanQuery();
> finalQuery.add(b1,BooleanClause.Occur.SHOULD);
> finalQuery.add(b2,BooleanClause.Occur.SHOULD); 
> 
> 
>       
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Generating-Query-tp24931880p24943981.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.


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