Closed remorses closed 1 year ago
@remorses exactly as you say: running indexing and search inside a web worker is possible, but it is a trade off. On one hand, it makes it possible to perform indexing without blocking the main thread, on the other hand it introduces complexity and might make search slower when long result lists have to be exchanged.
My own experience is that for most cases, keeping MiniSearch
on the main thread (possibly indexing asynchronously with addAllAsync
to avoid blocking) is preferable and more maintainable. I did encounter a couple of cases that were implemented with a web worker, but that’s not how I would generally start.
Thank you for the explanation :)
Does it make sense to wrap fetching and searching inside a worker?
Did you already do some benchmarks with this approach?
I assume using a worker would not be optimal if there are many results to pass back to the main thread