faiss-db-client
v0.4.1
Published
Node.js client for [faissdb](https://github.com/crumbjp/faissdb), a replicated vector database built on FAISS and RocksDB.
Readme
faiss-db-client
Node.js client for faissdb, a replicated vector database built on FAISS and RocksDB.
Install
npm install faiss-db-clientUsage
const { ReplicaSet } = require('faiss-db-client');
const client = new ReplicaSet({
connects: [
{ host: 'localhost', port: 20021 },
{ host: 'localhost', port: 20022 },
{ host: 'localhost', port: 20023 },
],
});
client.init();
// Upsert vectors (writes go to the primary automatically)
await client.set([
{ key: 'k1', v: [0.1, 0.2], collections: ['main', 'sub'] },
]);
// Update collection membership without resending the vector (faissdb >= 0.4.0)
await client.setCollections([
{ key: 'k1', collections: ['main'] },
]);
// Search a collection (reads are balanced to secondaries)
const [keys, distances] = await client.search('main', 10, [0.1, 0.2]);
// Delete
await client.del(['k1']);Sparse vectors are also accepted: pass v as an object of { index: value } instead of an array.
Other operations: train(proportion), dropall(), dbstats(), status(). A single-node Client class is exported as well.
