lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From AHMET ARSLAN <iori...@yahoo.com>
Subject Re: Generating Query
Date Wed, 12 Aug 2009 09:27:23 GMT
> 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


Mime
View raw message