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 2005/05/15 19:41:01 UTC
DO NOT REPLY [Bug 32115] -
[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
------- Additional Comments From john.wang@gmail.com 2005-05-15 19:40 -------
Created an attachment (id=15037)
--> (http://issues.apache.org/bugzilla/attachment.cgi?id=15037&action=view)
Added multifield selective boost functionality to MultiFieldQueryParser class.
The attachment includes the changes made in the attachment 15036 for bug 33848.
Here is the unit test I used:
String[] fields=new String[]{"f1","f2","f3","f4","f5"};
HashMap boostMap=new HashMap();
boostMap.put("f2",new Float(1.2));
boostMap.put("f3",new Float(1.3));
MultiFieldQueryParser parser=new
MultiFieldQueryParser(fields,new TestAnalyzer(fields));
parser.setBoostMap(boostMap);
String qString="bla AND blo";
Query q=parser.parse(qString);
//Query q=QueryParser.parse(qString,"f1",new
TestAnalyzer(fields));
//Query q=MultiFieldQueryParser.parse(qString,fields,new
TestAnalyzer(fields));
System.out.println(q);
}
static class TestAnalyzer extends Analyzer{
String[] _defaultFields;
StandardAnalyzer _std;
public TestAnalyzer(String[] defaultFields){
_defaultFields=defaultFields;
_std=new StandardAnalyzer();
}
public TokenStream tokenStream(String fieldName, Reader reader)
{
if ("f1".equals(fieldName)){
return new EmptyTokenStream();
}
else{
return _std.tokenStream(fieldName, reader);
}
}
private static class EmptyTokenStream extends TokenStream{
public Token next() throws IOException {
return null;
}
}
}
--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org