You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by ho...@apache.org on 2006/09/13 01:11:59 UTC

svn commit: r442752 - in /incubator/solr/trunk/src/java/org/apache/solr/request: SimpleFacets.java SolrParams.java

Author: hossman
Date: Tue Sep 12 16:11:58 2006
New Revision: 442752

URL: http://svn.apache.org/viewvc?view=rev&rev=442752
Log:
small tweak: facet.limit now assumes a sensible default of 100 to prevent extreme amounts of data from being returned to a naive client.  negative values for facet.limit force the limitless behavior

Modified:
    incubator/solr/trunk/src/java/org/apache/solr/request/SimpleFacets.java
    incubator/solr/trunk/src/java/org/apache/solr/request/SolrParams.java

Modified: incubator/solr/trunk/src/java/org/apache/solr/request/SimpleFacets.java
URL: http://svn.apache.org/viewvc/incubator/solr/trunk/src/java/org/apache/solr/request/SimpleFacets.java?view=diff&rev=442752&r1=442751&r2=442752
==============================================================================
--- incubator/solr/trunk/src/java/org/apache/solr/request/SimpleFacets.java (original)
+++ incubator/solr/trunk/src/java/org/apache/solr/request/SimpleFacets.java Tue Sep 12 16:11:58 2006
@@ -182,10 +182,9 @@
     Set<CountPair<String,Integer>> counts 
       = new HashSet<CountPair<String,Integer>>();
 
-    String limit = params.getFieldParam(fieldName, params.FACET_LIMIT);
-    if (null != limit) {
-      counts = new BoundedTreeSet<CountPair<String,Integer>>
-        (Integer.parseInt(limit));
+    int limit = params.getFieldInt(fieldName, params.FACET_LIMIT, 100);
+    if (0 <= limit) {
+      counts = new BoundedTreeSet<CountPair<String,Integer>>(limit);
     }
 
     boolean zeros = params.getFieldBool(fieldName, params.FACET_ZEROS, true);

Modified: incubator/solr/trunk/src/java/org/apache/solr/request/SolrParams.java
URL: http://svn.apache.org/viewvc/incubator/solr/trunk/src/java/org/apache/solr/request/SolrParams.java?view=diff&rev=442752&r1=442751&r2=442752
==============================================================================
--- incubator/solr/trunk/src/java/org/apache/solr/request/SolrParams.java (original)
+++ incubator/solr/trunk/src/java/org/apache/solr/request/SolrParams.java Tue Sep 12 16:11:58 2006
@@ -160,6 +160,13 @@
     String val = get(param);
     return val==null ? def : Integer.parseInt(val);
   }
+  
+  /** Returns the int value of the field param, 
+  or the value for param, or def if neither is set. */
+  public int getFieldInt(String field, String param, int def) {
+    String val = getFieldParam(field, param);
+    return val==null ? def : Integer.parseInt(val);
+  }
 
   /** Returns the Float value of the param, or null if not set */
   public Float getFloat(String param) {