[#62,facets,backend/memory][m]: add faceting support to memory backend.

This commit is contained in:
Rufus Pollock
2012-04-01 16:31:36 +01:00
parent 80165659b1
commit 7a95302760
4 changed files with 87 additions and 38 deletions

View File

@@ -152,15 +152,25 @@ my.Query = Backbone.Model.extend({
facets[fieldId] = {
terms: { field: fieldId }
};
this.set({facets: facets});
// for some reason this does not trigger automatically ...
this.trigger('change', this);
this.set({facets: facets}, {silent: true});
this.trigger('facet:add', this);
}
});
// ## A Facet (Result)
my.Facet = Backbone.Model.extend({
defaults: {
_type: 'terms',
// total number of tokens in the facet
total: 0,
// number of facet values not included in the returned facets
other: 0,
// number of documents which have no value for the field
missing: 0,
// term object ({term: , count: ...})
terms: []
}
});
// ## A Collection/List of Facets