We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi,
Is there a way to pass in a promise to initialize lunr instead of a function?
I want to do a non-blocking stream read to load data for lunr to index, a promise would allow me to keep things async. Any suggestions?
Thanks
The text was updated successfully, but these errors were encountered:
Hi
BTW this is not an issue IMMO.
just wrap into a Promise the lunr() index creation:
lunr()
function createLunrIndex(documents,fieldNames) { return new Promise( (resolve,reject) => { const idx = lunr(function() { // // load documents // set fields // ... }) resolve(idx) }); } const idx = await createLunrIndex(documents,fieldNames, ...)
I want to do a non-blocking stream read to load data for lunr to index,
Do you want to add documents dynamically after the index creation? This is maybe not possible, see: https://stackoverflow.com/a/44086343/1786393
So I fair you have to recreated the index when you have new documents to add.
Maybe that's a change request, not an issue.
Sorry, something went wrong.
async function createIndex(): Promise<lunr.Index>{ const builder = new lunr.Builder(); builder.pipeline.add( lunr.trimmer, lunr.stopWordFilter, lunr.stemmer ) builder.searchPipeline.add( lunr.stemmer ) builder.ref('id'); builder.field('keywords'); await addObjectsToIndex(); return builder.build(); } async function addObjectsToIndex():Promise<void>{ // do async stuff here }
No branches or pull requests
Hi,
Is there a way to pass in a promise to initialize lunr instead of a function?
I want to do a non-blocking stream read to load data for lunr to index, a promise would allow me to keep things async. Any suggestions?
Thanks
The text was updated successfully, but these errors were encountered: