lucaong / minisearch

Tiny and powerful JavaScript full-text search engine for browser and Node
https://lucaong.github.io/minisearch/
MIT License
4.64k stars 133 forks source link

Any notification on status of data loading? #248

Closed hyp530 closed 6 months ago

hyp530 commented 6 months ago

When there is a lot of content, the initial search requires a long waiting time for data loading (It takes 50 seconds on my site ).

Any solution to improve the search experience? Or any API to check the status of data loading, so that I can add a notification to inform the users?

Thank you

lucaong commented 6 months ago

Hi @hyp530 , if you use the addAllAsync method to index your documents (which is probably a good idea if your indexing phase takes a long time, to avoid blocking the UI), then the promise returned by the method call will resolve when the indexing is finished. You can therefore use it to indicate in the UI when the search is ready.

You also might want to tweak the chunkSize option passed to addAllAsync, as the default setting is quite conservative and might result in slow indexing: a larger chunkSize will make indexing faster, but too large could block the UI thread. Ideally, you would set it to the largest value that does not block the UI while indexing (as in, your app is still responsive to click, scroll, etc. while indexing).

That said, 50 seconds sounds like a really long time. Is this the indexing time, or the time it takes to load the data from an API? If it is indexing, is your collection of documents very large, or the documents very big? If not, there might be some bottleneck that could be optimized. Oddly, if I visit https://www.airgaap.com/, for me the indexing is immediate.