bleroy/lunr-core

Will indexes remain immutable?

Closed this issue · 2 comments

I noticed that lunr.js has decided on immutable indexes. Does lunr-core intend to adhere to this design goal? IMO, while feature parity with lunr.js is a laudable goal (and the point of this whole package even), the inability to add or remove individual documents reduces the usefulness of lunr-core server-side where lunr.js may not be used at all, and rebuilding the entire index for each document add/change/delete is not practical.

Not necessarily. At this point it's a plain port so it does whatever lunr.js does.

@drittich

The mutable disk-based index (via LMDB) is merged to main, you can use it now and let me know what you think in terms of how to approach mutable documents.

Right now, it can be used to persist pre-built indexes to disk for later referencing, and the data structures (fields, field vectors, and inverted index entries), can be added independently via LmdbIndex.

I'm still thinking about how to rebalance the index efficiently when documents are added or removed, as rebuilding the entire thing doesn't get us much further along.

(It's probably going to look like an API that takes Document and converts it into its component structures and mutates the data in place. But I'm not an expert in how lunr-js works, so I don't know what to expect in terms of statistics or rebalancing or pruning the B-tree)