https://github.com/serenysoft/rxdb-flexsearch
RxDB Plugin based on FlexSearch implementation
https://github.com/serenysoft/rxdb-flexsearch
flexsearch fulltext-search fuzzy fuzzy-search javascript nodejs rxdb search searching typescript
Last synced: 5 months ago
JSON representation
RxDB Plugin based on FlexSearch implementation
- Host: GitHub
- URL: https://github.com/serenysoft/rxdb-flexsearch
- Owner: serenysoft
- Created: 2023-08-02T20:29:43.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2023-08-03T22:44:44.000Z (almost 3 years ago)
- Last Synced: 2025-09-23T20:18:00.701Z (9 months ago)
- Topics: flexsearch, fulltext-search, fuzzy, fuzzy-search, javascript, nodejs, rxdb, search, searching, typescript
- Language: TypeScript
- Homepage:
- Size: 21.5 KB
- Stars: 11
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# [RxDB](https://rxdb.info) - [FlexSearch](https://github.com/nextapps-de/flexsearch) plugin
[](https://github.com/serenysoft/rxdb-flexsearch/actions/workflows/ci.yml)
[](https://codecov.io/gh/serenysoft/rxdb-flexsearch)
## Install
```cli
npm i rxdb-flexsearch flexsearch@0.7.21 --save
```
## Usage
```js
import { addRxPlugin } from 'rxdb';
import { getRxStorageMemory } from 'rxdb/plugins/storage-memory';
import { RxDBFlexSearchPlugin } from 'rxdb-flexsearch';
import { userSchema } from './schemas';
addRxPlugin(RxDBFlexSearchPlugin);
const database = await createRxDatabase({
storage: getRxStorageMemory(),
});
await database.addCollections({
users: {
schema: userSchema,
options: {
searchable: true,
},
},
});
...
const results = await collection.search(query: string);
console.log(results);
```
## Import/Export indexes
```js
await database.exportIndexes((key, data) => {
localStorage.setItem(key, data);
});
await database.importIndexes({
[key]: localStorage.getItem(key);
});
```
You can use the `autoIndexExport` database option to automatically export indexes when the collection is modified.
```js
const database = await createRxDatabase({
storage: getRxStorageMemory(),
options: {
autoIndexExport: (key, value) => {
localStorage.setItem(key, value);
},
}
});
```