olivernn / lunr.js

A bit like Solr, but much smaller and not as bright
http://lunrjs.com
MIT License
8.96k stars 548 forks source link

Using workers to speed things up. #59

Closed mateuszjarzewski closed 10 years ago

mateuszjarzewski commented 10 years ago

This is not really a issue, more like feature request. Can you guys give me good reason for not using workers in this project?

olivernn commented 10 years ago

You can certainly use lunr from within a web worker, I have used it this way on at least one project and it works well. You won't necessarily get any performance boost, but you do get the advantage of taking the load of the ui thread.

You could get quite clever and split indexing across multiple web workers, @garysieling wrote some excellent blog posts relating to this. This way you could get a bit of concurrency in the indexing, and potentially searching of the index.

Having this built into lunr.js itself is way beyond the scope of what I think the library should provide though. Keep in mind that currently it works in all major browsers, some old ones (with shims) and node.js, this would not be possible if it relied on WebWorkers. Having said that there is nothing stopping you from creating some kind of wrapper library, that does the work of making lunr work acrross multiple WebWorkers, in fact I would be very interested in a project like this coming to light! :smile: