Permalink
Browse files

add support for setting parameters when defining an AbstractFacetWidg…

…et, add parameters that can be set multiple times from Solr 3.1
1 parent 42a255b commit 55f296507d7255b075a986d036647c1ff7b02194 @jpmckinney jpmckinney committed Feb 10, 2011
Showing with 57 additions and 1 deletion.
  1. +1 −0 Rakefile
  2. +55 −0 core/AbstractFacetWidget.js
  3. +1 −1 core/ParameterStore.js
View
@@ -10,6 +10,7 @@ task :aggregate, :compress do |t, args|
'Core',
'AbstractManager',
'ParameterStore',
+ 'Parameter',
'AbstractWidget',
'AbstractFacetWidget'
]
@@ -18,6 +18,61 @@ AjaxSolr.AbstractFacetWidget = AjaxSolr.AbstractWidget.extend(
*/
field: null,
+ init: function () {
+ this.initStore();
+ },
+
+ /**
+ * Add facet parameters to the parameter store.
+ */
+ initStore: function () {
+ /* http://wiki.apache.org/solr/SimpleFacetParameters */
+ var parameters = [
+ 'facet.prefix',
+ 'facet.sort',
+ 'facet.limit',
+ 'facet.offset',
+ 'facet.mincount',
+ 'facet.missing',
+ 'facet.method',
+ 'facet.enum.cache.minDf'
+ ];
+
+ this.manager.store.addByValue('facet', true);
+
+ if (this['facet.field'] !== undefined) {
+ this.manager.store.addByValue('facet.field', this.field);
+ }
+ else if (this['facet.date'] !== undefined) {
+ this.manager.store.addByValue('facet.date', this.field);
+ parameters = parameters.concat([
+ 'facet.date.start',
+ 'facet.date.end',
+ 'facet.date.gap',
+ 'facet.date.hardend',
+ 'facet.date.other',
+ 'facet.date.include'
+ ]);
+ }
+ else if (this['facet.range'] !== undefined) {
+ this.manager.store.addByValue('facet.range', this.field);
+ parameters = parameters.concat([
+ 'facet.range.start',
+ 'facet.range.end',
+ 'facet.range.gap',
+ 'facet.range.hardend',
+ 'facet.range.other',
+ 'facet.range.include'
+ ]);
+ }
+
+ for (var i = 0, l = parameters.length; i < l; i++) {
+ if (this[parameters[i]] !== undefined) {
+ this.manager.store.addByValue('f.' + this.field + '.' + parameters[i], this[parameters[i]]);
+ }
+ }
+ },
+
/**
* @returns {Boolean} Whether any filter queries have been set using this
* widget's facet field.
View
@@ -79,7 +79,7 @@ AjaxSolr.ParameterStore = AjaxSolr.Class.extend(
* @see http://lucene.apache.org/solr/api/org/apache/solr/handler/DisMaxRequestHandler.html
*/
isMultiple: function (name) {
- return name.match(/^(?:bf|bq|facet\.date|facet\.date\.other|facet\.field|facet\.query|fq|pf|qf)$/);
+ return name.match(/^(?:bf|bq|facet\.date|facet\.date\.other|facet\.date\.include|facet\.field|facet\.range|facet\.range\.other|facet\.range\.include|facet\.query|fq|pf|qf)$/);
},
/**

0 comments on commit 55f2965

Please sign in to comment.