fergiemcdowall / search-index

A persistent, network resilient, full text search library for the browser and Node.js
MIT License
1.38k stars 149 forks source link

Initializing with an instance of Level #610

Closed kldavis4 closed 1 year ago

kldavis4 commented 1 year ago

Is it possible to initialize SearchIndex with an already initialized Level db? It seems to expect the Level class and not allow an instance to be passed. If that is the case, how can configuration options be passed to the constructor of the Level class?

In my case, I am using ManyLevelGuest and need to specify the port that it should connect with. I am able to work around the issue by wrapping the instance in an ES6 class, but wondering if there is something more conventional I should be doing.

kldavis4 commented 1 year ago

I'm wondering if something like adding dbManifest / dbOptions (as per https://github.com/Level/abstract-level/blob/main/types/abstract-level.d.ts#L35) would work. Then when the db is instantiated in the fii they could be passed.

kldavis4 commented 1 year ago

Looks like this PR to fii https://github.com/fergiemcdowall/fergies-inverted-index/pull/45 would potentially resolve things.

fergiemcdowall commented 1 year ago

Hi @kldavis4 and sorry for the late reply- there is a lot going on here just now!

There is an example in the tests- would something like this work? -> https://github.com/fergiemcdowall/search-index/blob/master/test/src/memory-level-test.js#L40-L43

fergiemcdowall commented 1 year ago

search-index@4 now uses abstract-level