lucaong / minisearch

Tiny and powerful JavaScript full-text search engine for browser and Node
https://lucaong.github.io/minisearch/
MIT License
4.49k stars 133 forks source link

Get Mini Search version? #251

Open oiver555 opened 4 months ago

oiver555 commented 4 months ago

I'm using Minisearch in my app, which was published about a year or two ago. I just made an update of the app a few days ago, updating Minisearch to version 5.0.0, everything works fine however, I notice users get this error...

Fatal Exception: com.facebook.react.common.JavascriptException: Error: MiniSearch: cannot deserialize an index created with an incompatible version

...when using the old index from the old version of my app, in the updated version of my app. Is there a way I can obtain the version of Minisearch from it's instance, so that I can make a new index when the conditions require it. Or maybe you have a better solution? Thank you for your time and help!

lucaong commented 4 months ago

Hi @oiver555 , MiniSearch follows semantic versioning: breaking changes are only introduced with major releases. In other words, as long as the first version number does not change (the x in x.y.z), you can safely upgrade. A common strategy to avoid bad surprises when updating is to pin the major version of the library in your package.json, by specifying your dependency as "minisearch": "^6.3.0". This will update MiniSearch automatically to any new minor or patch version, but not if the major version changes (so you can perform the major updates manually when you are ready, checking the CHANGELOG for breaking changes and how to deal with them).

MiniSearch also tries to avoid breaking changes to the serialization format, even upon major version changes. So far, version 4.0.0 is the only one that introduced a breaking change in the serialization format.

That said, it might be useful to obtain the current version from the MiniSearch instance, as you propose. I will look into it for the next update.

Thanks for opening the issue!

oiver555 commented 4 months ago

Understood, thanks for the response and protocol