Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add support for setting parameters when defining an AbstractFacetWidg…

…et, add parameters that can be set multiple times from Solr 3.1
  • Loading branch information...
commit 55f296507d7255b075a986d036647c1ff7b02194 1 parent 42a255b
@jpmckinney jpmckinney authored
View
1  Rakefile
@@ -10,6 +10,7 @@ task :aggregate, :compress do |t, args|
'Core',
'AbstractManager',
'ParameterStore',
+ 'Parameter',
'AbstractWidget',
'AbstractFacetWidget'
]
View
55 core/AbstractFacetWidget.js
@@ -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
2  core/ParameterStore.js
@@ -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)$/);
},
/**
Please sign in to comment.
Something went wrong with that request. Please try again.