lucene-solr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hoss...@apache.org
Subject svn commit: r888136 - in /lucene/solr/trunk: CHANGES.txt src/java/org/apache/solr/request/SimpleFacets.java src/test/org/apache/solr/request/SimpleFacetsTest.java
Date Mon, 07 Dec 2009 21:04:13 GMT
Author: hossman
Date: Mon Dec  7 21:04:09 2009
New Revision: 888136

URL: http://svn.apache.org/viewvc?rev=888136&view=rev
Log:
SOLR-343: Date faceting now respects facet.mincount limiting

Modified:
    lucene/solr/trunk/CHANGES.txt
    lucene/solr/trunk/src/java/org/apache/solr/request/SimpleFacets.java
    lucene/solr/trunk/src/test/org/apache/solr/request/SimpleFacetsTest.java

Modified: lucene/solr/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/CHANGES.txt?rev=888136&r1=888135&r2=888136&view=diff
==============================================================================
--- lucene/solr/trunk/CHANGES.txt (original)
+++ lucene/solr/trunk/CHANGES.txt Mon Dec  7 21:04:09 2009
@@ -110,6 +110,9 @@
 * SOLR-1628: log contains incorrect number of adds and deletes. 
   (Thijs Vonk via yonik)
 
+* SOLR-343: Date faceting now respects facet.mincount limiting
+  (Uri Boness, Raiko Eckstein via hossman)
+
 * SOLR-1624: Highlighter only highlights values from the first field  value
   in a multivalued field when term positions (term vectors) are stored.
   (Chris Harris via yonik)

Modified: lucene/solr/trunk/src/java/org/apache/solr/request/SimpleFacets.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/request/SimpleFacets.java?rev=888136&r1=888135&r2=888136&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/request/SimpleFacets.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/request/SimpleFacets.java Mon Dec  7 21:04:09
2009
@@ -596,7 +596,9 @@
       final String gap = required.getFieldParam(f,FacetParams.FACET_DATE_GAP);
       final DateMathParser dmp = new DateMathParser(ft.UTC, Locale.US);
       dmp.setNow(NOW);
-      
+
+      int minCount = params.getFieldInt(f,FacetParams.FACET_MINCOUNT, 0);
+
       try {
         
         Date low = start;
@@ -617,7 +619,10 @@
               (SolrException.ErrorCode.BAD_REQUEST,
                "date facet infinite loop (is gap negative?)");
           }
-          resInner.add(label, rangeCount(sf,low,high,true,true));
+          int count = rangeCount(sf,low,high,true,true);
+          if (count >= minCount) {
+            resInner.add(label, count);
+          }
           low = high;
         }
       } catch (java.text.ParseException e) {

Modified: lucene/solr/trunk/src/test/org/apache/solr/request/SimpleFacetsTest.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/org/apache/solr/request/SimpleFacetsTest.java?rev=888136&r1=888135&r2=888136&view=diff
==============================================================================
--- lucene/solr/trunk/src/test/org/apache/solr/request/SimpleFacetsTest.java (original)
+++ lucene/solr/trunk/src/test/org/apache/solr/request/SimpleFacetsTest.java Mon Dec  7 21:04:09
2009
@@ -284,6 +284,58 @@
             
             );
 
+    assertQ("check counts for month of facet by day with global mincount = 1",
+            req( "q", "*:*"
+                ,"rows", "0"
+                ,"facet", "true"
+                ,"facet.date", f
+                ,"facet.date.start", "1976-07-01T00:00:00.000Z"
+                ,"facet.date.end",   "1976-07-01T00:00:00.000Z+1MONTH"
+                ,"facet.date.gap",   "+1DAY"
+                ,"facet.date.other", "all"
+                ,"facet.mincount", "1"
+                )
+            // 31 days + pre+post+inner = 34
+            ,"*[count("+pre+"/int)=11]"
+            ,pre+"/int[@name='1976-07-03T00:00:00Z'][.='2'  ]"
+            // july4th = 2 because exists doc @ 00:00:00.000 on July5
+            // (date faceting is inclusive)
+            ,pre+"/int[@name='1976-07-04T00:00:00Z'][.='2'  ]"
+            ,pre+"/int[@name='1976-07-05T00:00:00Z'][.='2'  ]"
+            ,pre+"/int[@name='1976-07-12T00:00:00Z'][.='1'  ]"
+            ,pre+"/int[@name='1976-07-13T00:00:00Z'][.='1'  ]"
+            ,pre+"/int[@name='1976-07-15T00:00:00Z'][.='2'  ]"
+            ,pre+"/int[@name='1976-07-21T00:00:00Z'][.='1'  ]"
+            ,pre+"/int[@name='1976-07-30T00:00:00Z'][.='1'  ]"
+            ,pre+"/int[@name='before' ][.='2']"
+            ,pre+"/int[@name='after'  ][.='1']"
+            ,pre+"/int[@name='between'][.='11']"
+            );
+
+    assertQ("check counts for month of facet by day with field mincount = 1",
+            req( "q", "*:*"
+                ,"rows", "0"
+                ,"facet", "true"
+                ,"facet.date", f
+                ,"facet.date.start", "1976-07-01T00:00:00.000Z"
+                ,"facet.date.end",   "1976-07-01T00:00:00.000Z+1MONTH"
+                ,"facet.date.gap",   "+1DAY"
+                ,"facet.date.other", "all"
+                ,"f." + f + ".facet.mincount", "2"
+                )
+            // 31 days + pre+post+inner = 34
+            ,"*[count("+pre+"/int)=7]"
+            ,pre+"/int[@name='1976-07-03T00:00:00Z'][.='2'  ]"
+            // july4th = 2 because exists doc @ 00:00:00.000 on July5
+            // (date faceting is inclusive)
+            ,pre+"/int[@name='1976-07-04T00:00:00Z'][.='2'  ]"
+            ,pre+"/int[@name='1976-07-05T00:00:00Z'][.='2'  ]"
+            ,pre+"/int[@name='1976-07-15T00:00:00Z'][.='2'  ]"
+            ,pre+"/int[@name='before' ][.='2']"
+            ,pre+"/int[@name='after'  ][.='1']"
+            ,pre+"/int[@name='between'][.='11']"
+            );
+
     assertQ("check hardend=false",
             req( "q", "*:*"
                 ,"rows", "0"



Mime
View raw message