Commit af5b97eb by Rashid Khan

Merge remote-tracking branch 'bleskes/feature/improve_bool_filter' into boazFilter

parents a926358a 30cda20e
...@@ -129,25 +129,32 @@ define([ ...@@ -129,25 +129,32 @@ define([
}; };
this.getBoolFilter = function(ids) { this.getBoolFilter = function(ids) {
// A default match all filter, just in case there are no other filters var bool = ejs.BoolFilter();
var bool = ejs.BoolFilter().must(ejs.MatchAllFilter()); // there is no way to introspect the BoolFilter and find out if it has a filter. We must keep note.
var either_bool = ejs.BoolFilter().must(ejs.MatchAllFilter()); var added_a_filter = false;
_.each(ids,function(id) { _.each(ids,function(id) {
if(self.list[id].active) { if(self.list[id].active) {
added_a_filter = true;
switch(self.list[id].mandate) switch(self.list[id].mandate)
{ {
case 'mustNot': case 'mustNot':
bool = bool.mustNot(self.getEjsObj(id)); bool.mustNot(self.getEjsObj(id));
break; break;
case 'either': case 'either':
either_bool = either_bool.should(self.getEjsObj(id)); bool.should(self.getEjsObj(id));
break; break;
default: default:
bool = bool.must(self.getEjsObj(id)); bool.must(self.getEjsObj(id));
} }
} }
}); });
return bool.must(either_bool); // add a match filter so we'd get some data
if (!added_a_filter) {
bool.must(ejs.MatchAllFilter());
}
return bool;
}; };
this.getEjsObj = function(id) { this.getEjsObj = function(id) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment