lucaong / minisearch

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

Does heavy indexing activity block ability to search? #217

Closed reubenfirmin closed 1 year ago

reubenfirmin commented 1 year ago

I have an issue in my application where search stops working intermittently while heavy indexing activity is happening. It seems to be happening within MiniSearch, but I'm not yet 100% on it. Does it sound possible? I saw references to "blocking the main thread" in the API docs, so I'm wondering if that's happening. Is there a workaround so that search is kept alive no matter what?

reubenfirmin commented 1 year ago

I'm leaning towards the index being corrupted. I will try a vacuum when this next happens to see if it fixes it.

lucaong commented 1 year ago

Hi @reubenfirmin , It is possible that heavy indexing block the main thread. If that’s the case, try using addAllAsync instead of addAll: indexing will slow down, but it will leave space for other operations such as search.

That said, without knowledge of your case it’s hard to say if indexing is the problem. In many cases I have seen, what blocks search is not so much indexing, but rather rendering long lists of results. If that’s the case, you'll notice it happening more when there are many results. One solution is to render the result list lazily upon scroll, a bit like “infinite scrolling”, or using something akin to react-window.

Regarding the index being possibly corrupted, what makes you think so?

reubenfirmin commented 1 year ago

@lucaong Thanks for the answer - I ruled this out. It's actually chrome shutting down my extension after some inactivity that causes this. I'm working on a fix.