lunr.js icon indicating copy to clipboard operation
lunr.js copied to clipboard

Lunr load and search only

Open misterdai opened this issue 8 years ago • 7 comments

Would it be feasible for the project to produce a build that only contained the minimal JS required for loading of a pre-built index and searching only? For my own use, I'm generating a static site and building the index once before deployment, so it'd be nice to have an even slimmer library to use in the browser where no index creation knowledge is required.

Or, point me in the right direction if this is already possible and I'm just being daft ;)

misterdai avatar Jun 01 '17 09:06 misterdai

It might be possible in the future. The current build system is a little basic, its basically just cat lib/*.js | uglify. I want to switch to using something like rollup.js which might also help with producing a 'client' only build.

That said, I'm not sure the size difference would be that large. The only class not used after the index is build is lunr.Builder, i.e. you might save a couple of kb. I guess if the rest of your site is super optimised it might still be worthwhile.

olivernn avatar Jun 03 '17 12:06 olivernn

And I need exactly the same - a pre-built index on the backend, and search-only part of the Lunr.js on the frontend. And what would be even more great - to build the index using Java! In my case - I already have the index in my Java program: this is a Lucene index (with all the stuff like synonyms, stemming, stopwords etc). How can I convert it into a format compatible with Lunr.js ?

stargazer33 avatar Jun 18 '17 16:06 stargazer33

@stargazer33 this is something that I'm very interested in pursuing, having Lunr as a front end to an index built by something else. Either because the backend can be more capable (i.e. Lucene) or for easier integration into other tools that can't or won't shell out to some Javascript build process.

I've been working on defining the schema required for a serialised index, I've got a rough version together already, using JSONSchema. I'll push up what I have in the next day or so, would you be interested in helping test this?

olivernn avatar Jun 18 '17 18:06 olivernn

Oliver, definitely! (I was thinking about running Javascript directly in Java using this approach https://github.com/olivernn/lunr.js/issues/26#issuecomment-43534876 but straight export of Lucene index is so much better! )

stargazer33 avatar Jun 18 '17 19:06 stargazer33

@stargazer33 I've just pushed my work in progress here - https://github.com/olivernn/lunr-schema

I think it's best to open a new issue to discuss a backend in another language (Java with Lucene), either in this repository or that repository.

As I say, its just a rough draft at the moment, but hopefully it is a good starting point.

olivernn avatar Jun 19 '17 18:06 olivernn

I came here looking for this (a Lunr.js build that only loads and searches an index). Lunr is already small and fast, but why not make it even smaller and faster by only loading what's really needed?

@olivernn 3 years later, has the build situation changed to make this more feasible?

nylen avatar May 04 '20 04:05 nylen

@nylen as mentioned further above, there isn't a huge amount of code that is only for building the index. I've also not prioritised updating the build system so nothing has changed on this issue.

olivernn avatar May 04 '20 09:05 olivernn