You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by bu...@apache.org on 2004/11/08 11:42:11 UTC
DO NOT REPLY [Bug 32115] New: -
[PATCH] add boost feature to MultiFieldQueryParser
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=32115>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=32115
[PATCH] add boost feature to MultiFieldQueryParser
Summary: [PATCH] add boost feature to MultiFieldQueryParser
Product: Lucene
Version: 1.4
Platform: Other
OS/Version: Other
Status: NEW
Severity: Enhancement
Priority: Other
Component: QueryParser
AssignedTo: lucene-dev@jakarta.apache.org
ReportedBy: nicoo_@hotmail.com
add this feature
(field1:query)^bfield1 (field2:query)^bfield12 (field3:query)^bfield3 ...
(fieldx:query)^bfieldx
Google Example: a user search "coco" , my defaults search fields are title and
description. But i would like boost title field more than description field to
have results more relevant.
Change in the MultiFieldQueryParser : add this method
public static Query parse(String query, String[] fields, int[] flags, float []
boost, 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(boost[i]);
int flag = flags[i];
switch (flag)
{
case REQUIRED_FIELD:
bQuery.add(q, BooleanClause.Occur.MUST);
break;
case PROHIBITED_FIELD:
bQuery.add(q, BooleanClause.Occur.MUST_NOT);
break;
default:
bQuery.add(q, BooleanClause.Occur.SHOULD);
break;
}
}
return bQuery;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-dev-help@jakarta.apache.org