flexsearch icon indicating copy to clipboard operation
flexsearch copied to clipboard

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

Open James-Hudson3010 opened this issue 4 years ago • 8 comments

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?

James-Hudson3010 avatar Jul 30 '21 12:07 James-Hudson3010

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".

ts-thomas avatar Jul 30 '21 12:07 ts-thomas

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 avatar Jul 30 '21 12:07 James-Hudson3010

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.

James-Hudson3010 avatar Jul 30 '21 13:07 James-Hudson3010

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

jamienicholls avatar Oct 31 '21 20:10 jamienicholls

@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.

ishanuda avatar Nov 01 '21 05:11 ishanuda

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

jamienicholls avatar Nov 01 '21 21:11 jamienicholls

@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

lostdesign avatar Nov 05 '21 13:11 lostdesign

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

ishanuda avatar Nov 07 '21 05:11 ishanuda

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

ts-thomas avatar Oct 03 '22 12:10 ts-thomas