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

git-svn-id: https://svn.apache.org/repos/asf/incubator/solr/trunk@442752 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Chris M. Hostetter 2006-09-12 23:11:58 +00:00
parent ec38c40d94
commit 6594c7c47d
2 changed files with 10 additions and 4 deletions

View File

@ -182,10 +182,9 @@ public class SimpleFacets {
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);

View File

@ -160,6 +160,13 @@ public abstract class SolrParams {
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) {