Improvement request : buckets sort
Bartaf83 opened this issue · comments
Ahmed Feki commented
It could be interesting to be able to sort buckets (alphabetically at least) or by any other possible criteria.
We wish see such as feature soon in your module.
Best Regards!
S commented
Hi @Bartaf83,
I think this is already possible with Itemsjs version 2.1.15.
You can check #109 tests/facetSortingSpec.js where the feature is added.
For example alphabetically facet sorting:
describe('facet sorting', function() {
it('sort by key', function test(done) {
const result = require('./../index')(items, {
aggregations: {
genres: {
sort: ['key'],
}
}
}).aggregation({
name: 'genres',
});
assert.deepEqual(result.data.buckets.map(v => v.key), ['Comedy', 'Drama', 'Horror', 'Romance', 'Western']);
done();
});
Mateusz commented
It will require better documentation / guide so any help is needed here but I am closing now because this feature is available