Apache Lucene open-source search software
SOLR-1932: assume no preflex here, these stats are new in 4.x indexes
Robert Muirae27b645a43c
diff --git a/solr/src/test/org/apache/solr/search/function/TestFunctionQuery.java b/solr/src/test/org/apache/solr/search/function/TestFunctionQuery.javaindex 021e5f48d2a..5d5aece809b 100755--- a/solr/src/test/org/apache/solr/search/function/TestFunctionQuery.java+++ b/solr/src/test/org/apache/solr/search/function/TestFunctionQuery.java@@ -18,6 +18,7 @@package org.apache.solr.search.function;import org.apache.lucene.index.FieldInvertState;+import org.apache.lucene.index.codecs.CodecProvider;import org.apache.lucene.search.DefaultSimilarity;import org.apache.lucene.search.FieldCache;import org.apache.lucene.search.Similarity;@@ -303,7 +304,6 @@ 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();@@ -396,6 +396,27 @@ public class TestFunctionQuery extends SolrTestCaseJ4 {purgeFieldCache(FieldCache.DEFAULT); // avoid FC insanity}+ /**+ * test collection-level term stats (new in 4.x indexes)+ */+ public void testTotalTermFreq() throws Exception {+ assumeFalse("PreFlex codec does not support collection-level term stats",+ "PreFlex".equals(CodecProvider.getDefault().getDefaultFieldCodec()));++ clearIndex();++ assertU(adoc("id","1", "a_tdt","2009-08-31T12:10:10.123Z", "b_tdt","2009-08-31T12:10:10.124Z"));+ assertU(adoc("id","2", "a_t","how now brown cow"));+ assertU(commit()); // create more than one segment+ assertU(adoc("id","3", "a_t","brown cow"));+ assertU(adoc("id","4"));+ assertU(commit()); // create more than one segment+ assertU(adoc("id","5"));+ assertU(adoc("id","6", "a_t","cow cow cow cow cow"));+ assertU(commit());+ assertQ(req("fl","*,score","q", "{!func}totaltermfreq('a_t','cow')", "fq","id:6"), "//float[@name='score']='7.0'");+ }+@Testpublic void testSortByFunc() throws Exception {assertU(adoc("id", "1", "const_s", "xx", "x_i", "100", "1_s", "a"));