SOLR-1932: add totaltermfreq to relevancy functions

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1142480 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2011-07-03 19:02:40 +00:00
parent b1afef02f9
commit b692d0cd6a
2 changed files with 9 additions and 0 deletions

View File

@ -540,6 +540,14 @@ public abstract class ValueSourceParser implements NamedListInitializedPlugin {
}
});
addParser("totaltermfreq", new ValueSourceParser() {
@Override
public ValueSource parse(FunctionQParser fp) throws ParseException {
TInfo tinfo = parseTerm(fp);
return new TotalTermFreqValueSource(tinfo.field, tinfo.val, tinfo.indexedField, tinfo.indexedBytes);
}
});
addParser("idf", new ValueSourceParser() {
@Override
public ValueSource parse(FunctionQParser fp) throws ParseException {

View File

@ -303,6 +303,7 @@ public class TestFunctionQuery extends SolrTestCaseJ4 {
assertQ(req("fl","*,score","q", "{!func}docfreq('a_t','cow')", "fq","id:6"), "//float[@name='score']='3.0'");
assertQ(req("fl","*,score","q", "{!func}docfreq($field,$value)", "fq","id:6", "field","a_t", "value","cow"), "//float[@name='score']='3.0'");
assertQ(req("fl","*,score","q", "{!func}termfreq(a_t,cow)", "fq","id:6"), "//float[@name='score']='5.0'");
assertQ(req("fl","*,score","q", "{!func}totaltermfreq('a_t','cow')", "fq","id:6"), "//float[@name='score']='7.0'");
Similarity similarity = new DefaultSimilarity();