[#66,filters,elasticsearch][s]: elasticsearch support for filters (addTermFilter on Query).
This commit is contained in:
@@ -79,6 +79,19 @@ this.recline.Backend = this.recline.Backend || {};
|
|||||||
}
|
}
|
||||||
delete out.q;
|
delete out.q;
|
||||||
}
|
}
|
||||||
|
// now do filters (note the *plural*)
|
||||||
|
if (out.filters && out.filters.length) {
|
||||||
|
if (!out.filter) {
|
||||||
|
out.filter = {}
|
||||||
|
}
|
||||||
|
if (!out.filter.and) {
|
||||||
|
out.filter.and = [];
|
||||||
|
}
|
||||||
|
out.filter.and = out.filter.and.concat(out.filters);
|
||||||
|
}
|
||||||
|
if (out.filters != undefined) {
|
||||||
|
delete out.filters;
|
||||||
|
}
|
||||||
return out;
|
return out;
|
||||||
},
|
},
|
||||||
query: function(model, queryObj) {
|
query: function(model, queryObj) {
|
||||||
|
|||||||
@@ -20,6 +20,12 @@ test("ElasticSearch queryNormalize", function() {
|
|||||||
in_.q = 'abc';
|
in_.q = 'abc';
|
||||||
var out = backend._normalizeQuery(in_);
|
var out = backend._normalizeQuery(in_);
|
||||||
equal(out.query.query_string.query, 'abc');
|
equal(out.query.query_string.query, 'abc');
|
||||||
|
|
||||||
|
var in_ = new recline.Model.Query();
|
||||||
|
in_.addTermFilter('xyz', 'XXX');
|
||||||
|
in_ = in_.toJSON();
|
||||||
|
var out = backend._normalizeQuery(in_);
|
||||||
|
deepEqual(out.filter.and[0], {term: { xyz: 'XXX'}});
|
||||||
});
|
});
|
||||||
|
|
||||||
var mapping_data = {
|
var mapping_data = {
|
||||||
|
|||||||
Reference in New Issue
Block a user