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

Prevent crashing when no items provided #141

Closed julievalet closed 6 months ago

julievalet commented 6 months ago

Hello there,

I use itemsjs in a Gatsby environnement, my items are loaded through API and sometimes it can return no items. When no items is provided when indexing, it crashes when doing a search.

The crash occurs when doing a facet union: Screenshot 2024-03-19 at 10 23 16 AM

Here is my fix for this issue. I also added a test for this case in the search spec.

Really appreciate your work with this library.

Thank you for considering my fix.

cigolpl commented 6 months ago

Thank you Julie. Merged and bumped version to 2.1.25