Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement request : buckets sort #110

Closed
Bartaf83 opened this issue Jun 8, 2022 · 2 comments
Closed

Improvement request : buckets sort #110

Bartaf83 opened this issue Jun 8, 2022 · 2 comments

Comments

@Bartaf83
Copy link

Bartaf83 commented Jun 8, 2022

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!

@Ruitjes
Copy link
Contributor

Ruitjes commented Jun 8, 2022

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();
  });

@cigolpl cigolpl changed the title Improovement request : buckets sort Improvement request : buckets sort Jul 27, 2022
@cigolpl
Copy link
Member

cigolpl commented Jul 28, 2022

It will require better documentation / guide so any help is needed here but I am closing now because this feature is available

@cigolpl cigolpl closed this as completed Jul 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants