lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "luqun lou" <loulu...@hotmail.com>
Subject MultiFieldQueryParser Problems about how to give the fields weight
Date Wed, 11 May 2005 15:49:34 GMT
    Now Suppose,There are two fields,"content","summary",but i think the 
query in content field may have highter weight than the summary field. how 
can i do it?
   I overload the parse function,and add weights which store every fields 
weights.
    public static Query parse(String query,String[] fields,float [] 
weights,Analyzer analyzer)
    throws ParseException
	{
    	BooleanQuery bQuery  = new BooleanQuery();
    	for(int i=0;i<fields.length;i++){
    		Query q = parse(query,fields[i],analyzer);
    		q.setBoost(weights[i]);
    		bQuery.add(q,false,false);
    	}
    	return bQuery;
    }
is it right?

_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar - get it now! 
http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/


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