itemsapi / itemsjs

Extremely fast faceted search engine in JavaScript - lightweight, flexible, and simple to use
Apache License 2.0
346 stars 41 forks source link

Paged filtered search not returning items #87

Closed joostmeijles closed 3 years ago

joostmeijles commented 3 years ago

When using filter with paging I do not get any results back.

Test case:

it('paged filtered search', function test(done) {
    const items = [{ id: 1 }, { id: 2 }, { id: 3 }];
    const index = require('./../index')(items);

    const res = index.search({
      query: '',
      page: 2,
      per_page: 1,
      filter: (item) => item.id > 1,
    });
    assert.deepEqual(res.data.items, [{ _id: 3, id: 3 }]);

    done();
  });

Is this a bug or am I using it wrongly?

joostmeijles commented 3 years ago

Fixed #88