Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run lunr.js on the server side in nodejs? #60

Closed
edgar-maciel opened this issue Jan 13, 2014 · 1 comment
Closed

run lunr.js on the server side in nodejs? #60

edgar-maciel opened this issue Jan 13, 2014 · 1 comment

Comments

@edgar-maciel
Copy link

@olivernn, help me with these questions:

  • how is possible run lunr.js on the server side in nodejs?
  • how can i save and retrieve the index on disk?

thank you

@olivernn
Copy link
Owner

There is an npm module, lunr which you can use in node. Other than requiring the module, as you would with any node module, there is no difference in how lunr works in a browser or in node.

As for persisting/loading the index, at the moment you can serialize an index with JSON.stringify and lunr.Index.load, actually saving this json to disk is not something that is part of lunr, you can implement that however best fits your use case.

For an example of using lunr from node, and serialising/loading an index, you can take a look at https://github.com/olivernn/lunr-index-builder/blob/master/bin/lunr-index-build. There is some other stuff in there specific to it being a command line app, but it should give you some ideas on how to run lunr in node.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants