diff --git a/solr/core/src/test/org/apache/solr/core/SOLR749Test.java b/solr/core/src/test/org/apache/solr/core/SOLR749Test.java index d3b5e32194f..d8028997ae2 100644 --- a/solr/core/src/test/org/apache/solr/core/SOLR749Test.java +++ b/solr/core/src/test/org/apache/solr/core/SOLR749Test.java @@ -23,9 +23,13 @@ import org.junit.BeforeClass; /** - * Test for https://issues.apache.org/jira/browse/SOLR-749 + * This class started life as a test for SOLR-749 to prove that value source plugins were properly + * intialized, but it has since evolved to also help prove that ValueSource's are not asked to compute + * values for documents unneccessarily. * - **/ + * @see CountUsageValueSourceParser + * @see SOLR-749 + */ public class SOLR749Test extends SolrTestCaseJ4 { @BeforeClass public static void beforeClass() throws Exception { @@ -73,15 +77,25 @@ public class SOLR749Test extends SolrTestCaseJ4 { "//result[@numFound=20]"); assertEquals(20, CountUsageValueSourceParser.getAndClearCount("func_q_wrapping_fq")); - assertQ("frange in complex bq w/ other mandatory clauses to check skipping", + assertQ("frange in complex boolean query w/ other mandatory clauses to check skipping", req("q","{!notfoo}(+id_i1:[20 TO 39] -id:25 +{!frange l=4.5 u=4.5 v='countUsage(frange_in_bq,4.5)'})"), "//result[@numFound=19]"); - + // don't assume specific clause evaluation ordering. // ideally this is 19, but could be as high as 20 depending on whether frange's // scorer has next() called on it before other clauses skipTo int count = CountUsageValueSourceParser.getAndClearCount("frange_in_bq"); assertTrue("frange_in_bq: " + count, (19 <= count && count <= 20)); + + assertQ("func in complex boolean query w/ constant scoring mandatory clauses", + req("q","{!notfoo}(+id_i1:[20 TO 29]^0 +{!frange l=4.5 u=4.5 v='countUsage(func_in_bq,4.5)'})"), + "//result[@numFound=10]"); + + // don't assume specific clause evaluation ordering. + // ideally this is 10, but could be as high as 11 depending on whether func's + // scorer has next() called on it before other clauses skipTo + count = CountUsageValueSourceParser.getAndClearCount("func_in_bq"); + assertTrue("func_in_bq: " + count, (10 <= count && count <= 11)); // non-cached frange queries should default to post-filtering // (ie: only be computed on candidates of other q/fq restrictions)