nextapps-de / flexsearch

Next-Generation full text search library for Browser and Node.js
Apache License 2.0
12.53k stars 491 forks source link

Question: Can indexes of documents be saved for reuse later? #249

Closed James-Hudson3010 closed 2 years ago

James-Hudson3010 commented 3 years ago

In my use case, the document I would like to search will not change. I would like to be able to pass this document to Flexsearch, have it create an index, and then save that pre-computed index so I can pass both the document and index to Flexsearch and begin receiving results immediately.

Is this possible?

ts-thomas commented 3 years ago

Flexsearch has an .export( ) method where you can store a serialized index, which could be imported via .import( ) later. Actually you need to enrich the IDs from the result with your document data. This is not automatically happened when you import an index yet. This is on my list for upcoming features "providing a simple workaround for restoring the full index including the document data".

James-Hudson3010 commented 3 years ago

I am not sure what you mean by "enrich the IDs from the result with the document data"? Can you expand on that?

James-Hudson3010 commented 3 years ago

Oh, looking at the documentation ( Document Search Options section ), I see:

enrich | Boolean | Enrich IDs from the results with the corresponding documents.

I am assuming you are referring to the need to use 'true' for the enrich value.

jamienicholls commented 3 years ago

I'm also having issues with exporting and importing document indexes, did you mange to get this to work @James-Hudson3010 ? I posted a question on Stack Overflow about my issue

ishanuda commented 3 years ago

@jamienicholls As I can see from the comment of the author above "This is on my list for upcoming features "providing a simple workaround for restoring the full index including the document data" it is still not working, and it will be added as a feature in the future releases.

jamienicholls commented 3 years ago

@ishanuda my bad, I miss read it.. Thanks for your reply :)

lostdesign commented 3 years ago

@jamienicholls i replied to your SO, cc @ishanuda / @James-Hudson3010 if you wanna know https://stackoverflow.com/questions/69760524/flexsearch-export-and-import-document-index-issue/69853828#69853828

ishanuda commented 3 years ago

@lostdesign, Hi, For the time being its a good solution. Thank you for the reminder.

ts-thomas commented 2 years ago

This is now fixed in v0.7.23 Further improvements to provide Promise.all() compatible export ist coming in next version.