Apache Lucene open-source search software
Some additional testing to prove 'defered function computation' in a syntax variant i was recently asked about
Chris Hostetter852f02b4b793
diff --git a/solr/core/src/test/org/apache/solr/core/SOLR749Test.java b/solr/core/src/test/org/apache/solr/core/SOLR749Test.javaindex 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 <a href="https://issues.apache.org/jira/browse/SOLR-749">SOLR-749</a>+ */public class SOLR749Test extends SolrTestCaseJ4 {@BeforeClasspublic 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 skipToint 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)