itemsapi / itemsjs

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

Prefilter is confusing #30

Closed domoritz closed 5 years ago

domoritz commented 5 years ago

I'm very confused by the prefiltering method and would appreciate your help and some improvements to the docs.


It is making items prefiltering before search or aggregation, i.e.:

itemsjs.prefilter(items) {
  return items.filter(item => {
    return item.price > 100;
  });
}
cigolpl commented 5 years ago

@domoritz good point. The part of prefilter in docs was quite confusing..

Answering questions:

  1. The prefilter function gives you an access to indexed items so you can narrow it down in the custom way i.e. by using js filter or slice function. The prefilter doesn't sound intuitively but no idea how to name it better.. I've added also now filter function which is just responsible for filtering items the same way like in lodash or in native js Array.prototype.filter(). There is a chance filter will cover most custom cases and prefilter could be deleted in the future.
  2. It's not valid function because it's not part of of ItemsJS API. It's a function argument in itemsjs.search function. The docs was incorrect about that and thanks for pointing that out! I've fixed that.
  3. The same as above
domoritz commented 5 years ago

Thank you so much for the prompt and comprehensive response. I am going to close this issue as solved.