From 6865a911d7d8d52750a77ccaaca9d538da16b0a5 Mon Sep 17 00:00:00 2001 From: Thomas Wilkerling Date: Mon, 5 May 2025 08:16:19 +0200 Subject: [PATCH 1/6] add deepwiki to readme --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index c0f8c2b..e6d78b4 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,8 @@ FlexSearch v0.8: [Overview and Migration Guide](doc/0.8.0.md) [Resolver](doc/resolver.md)  •  [Changelog](CHANGELOG.md) +[Ask DeepWiki.com](https://deepwiki.com/nextapps-de/flexsearch) + ## Please Support this Project FlexSearch has been helping developers around the world build powerful, efficient search functionalities for years. Maintaining and improving the library requires significant time and resources. If you’ve found this project valuable and you're interested in supporting the project, please consider donating. Thanks a lot for your continued support! From 042ef7f067937f04a9ce3fe9e161bc80c3f6c104 Mon Sep 17 00:00:00 2001 From: Thomas Wilkerling Date: Mon, 5 May 2025 08:48:50 +0200 Subject: [PATCH 2/6] make deepwiki badge more visible --- README.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index e6d78b4..61635ec 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ FlexSearch v0.8: [Overview and Migration Guide](doc/0.8.0.md) -

+ +[Ask DeepWiki.com](https://deepwiki.com/nextapps-de/flexsearch) + +

FlexSearch.js: Next-Generation full-text search library for Browser and Node.js

@@ -23,8 +26,6 @@ FlexSearch v0.8: [Overview and Migration Guide](doc/0.8.0.md) [Resolver](doc/resolver.md)  •  [Changelog](CHANGELOG.md) -[Ask DeepWiki.com](https://deepwiki.com/nextapps-de/flexsearch) - ## Please Support this Project FlexSearch has been helping developers around the world build powerful, efficient search functionalities for years. Maintaining and improving the library requires significant time and resources. If you’ve found this project valuable and you're interested in supporting the project, please consider donating. Thanks a lot for your continued support! @@ -40,13 +41,13 @@ FlexSearch has been helping developers around the world build powerful, efficien
- Donate using Open Collective
+ Donate using Open Collective
Antithesis Operations LLC

-FlexSearch performs queries up to 1,000,000 times faster compared to other libraries by also providing powerful search capabilities like multi-field search (document search), phonetic transformations, partial matching, tag-search or suggestions. +FlexSearch performs queries up to 1,000,000 times faster compared to other libraries by also providing powerful search capabilities like multi-field search (document search), phonetic transformations, partial matching, tag-search, result highlighting or suggestions. Bigger workloads are scalable through workers to perform any updates or queries to the index in parallel through dedicated balanced threads. @@ -563,9 +564,9 @@ The **_dist_** folder is located in: `node_modules/flexsearch/dist/` File Size (gzip) - 14.0 kb - 9.0 kb - 4.4 kb + 16.3 kb + 11.4 kb + 4.5 kb From 58c1a09cfdf2a72cbcc0d95db22f579e461be248 Mon Sep 17 00:00:00 2001 From: Thomas Wilkerling Date: Tue, 6 May 2025 09:01:12 +0200 Subject: [PATCH 3/6] add index.d.ts for persistent adapter --- src/db/clickhouse/index.d.ts | 41 ++++++++++++++++++++++++++++++++++++ src/db/indexeddb/index.d.ts | 41 ++++++++++++++++++++++++++++++++++++ src/db/mongodb/index.d.ts | 41 ++++++++++++++++++++++++++++++++++++ src/db/postgres/index.d.ts | 41 ++++++++++++++++++++++++++++++++++++ src/db/redis/index.d.ts | 41 ++++++++++++++++++++++++++++++++++++ src/db/sqlite/index.d.ts | 41 ++++++++++++++++++++++++++++++++++++ 6 files changed, 246 insertions(+) create mode 100644 src/db/clickhouse/index.d.ts create mode 100644 src/db/indexeddb/index.d.ts create mode 100644 src/db/mongodb/index.d.ts create mode 100644 src/db/postgres/index.d.ts create mode 100644 src/db/redis/index.d.ts create mode 100644 src/db/sqlite/index.d.ts diff --git a/src/db/clickhouse/index.d.ts b/src/db/clickhouse/index.d.ts new file mode 100644 index 0000000..4ea4f70 --- /dev/null +++ b/src/db/clickhouse/index.d.ts @@ -0,0 +1,41 @@ +declare module "flexsearch/db/clickhouse" { + + type IdType = + "text" | + "char" | + "varchar" | + "string" | + "number" | + "numeric" | + "integer" | + "smallint" | + "tinyint" | + "mediumint" | + "int" | + "int8" | + "uint8" | + "int16" | + "uint16" | + "int32" | + "uint32" | + "int64" | + "uint64" | + "bigint"; + + type PersistentOptions = { + name?: string; + type?: IdType; + db?: any; + }; + + export default class StorageInterface { + constructor(name: string, config: PersistentOptions); + constructor(config: string | PersistentOptions); + //mount(index: Index | Document) : Promise; + open() : Promise; + close() : Promise; + destroy() : Promise; + clear() : Promise; + db: any; + } +} diff --git a/src/db/indexeddb/index.d.ts b/src/db/indexeddb/index.d.ts new file mode 100644 index 0000000..0a9f5c0 --- /dev/null +++ b/src/db/indexeddb/index.d.ts @@ -0,0 +1,41 @@ +declare module "flexsearch/db/indexeddb" { + + type IdType = + "text" | + "char" | + "varchar" | + "string" | + "number" | + "numeric" | + "integer" | + "smallint" | + "tinyint" | + "mediumint" | + "int" | + "int8" | + "uint8" | + "int16" | + "uint16" | + "int32" | + "uint32" | + "int64" | + "uint64" | + "bigint"; + + type PersistentOptions = { + name?: string; + type?: IdType; + db?: IDBDatabase; + }; + + export default class StorageInterface { + constructor(name: string, config: PersistentOptions); + constructor(config: string | PersistentOptions); + //mount(index: Index | Document) : Promise; + open() : Promise; + close() : Promise; + destroy() : Promise; + clear() : Promise; + db: IDBDatabase; + } +} diff --git a/src/db/mongodb/index.d.ts b/src/db/mongodb/index.d.ts new file mode 100644 index 0000000..44b09d2 --- /dev/null +++ b/src/db/mongodb/index.d.ts @@ -0,0 +1,41 @@ +declare module "flexsearch/db/mongodb" { + + type IdType = + "text" | + "char" | + "varchar" | + "string" | + "number" | + "numeric" | + "integer" | + "smallint" | + "tinyint" | + "mediumint" | + "int" | + "int8" | + "uint8" | + "int16" | + "uint16" | + "int32" | + "uint32" | + "int64" | + "uint64" | + "bigint"; + + type PersistentOptions = { + name?: string; + type?: IdType; + db?: any; + }; + + export default class StorageInterface { + constructor(name: string, config: PersistentOptions); + constructor(config: string | PersistentOptions); + //mount(index: Index | Document) : Promise; + open() : Promise; + close() : Promise; + destroy() : Promise; + clear() : Promise; + db: any; + } +} diff --git a/src/db/postgres/index.d.ts b/src/db/postgres/index.d.ts new file mode 100644 index 0000000..6ea0129 --- /dev/null +++ b/src/db/postgres/index.d.ts @@ -0,0 +1,41 @@ +declare module "flexsearch/db/postgres" { + + type IdType = + "text" | + "char" | + "varchar" | + "string" | + "number" | + "numeric" | + "integer" | + "smallint" | + "tinyint" | + "mediumint" | + "int" | + "int8" | + "uint8" | + "int16" | + "uint16" | + "int32" | + "uint32" | + "int64" | + "uint64" | + "bigint"; + + type PersistentOptions = { + name?: string; + type?: IdType; + db?: any; + }; + + export default class StorageInterface { + constructor(name: string, config: PersistentOptions); + constructor(config: string | PersistentOptions); + //mount(index: Index | Document) : Promise; + open() : Promise; + close() : Promise; + destroy() : Promise; + clear() : Promise; + db: any; + } +} diff --git a/src/db/redis/index.d.ts b/src/db/redis/index.d.ts new file mode 100644 index 0000000..a1c6df9 --- /dev/null +++ b/src/db/redis/index.d.ts @@ -0,0 +1,41 @@ +declare module "flexsearch/db/redis" { + + type IdType = + "text" | + "char" | + "varchar" | + "string" | + "number" | + "numeric" | + "integer" | + "smallint" | + "tinyint" | + "mediumint" | + "int" | + "int8" | + "uint8" | + "int16" | + "uint16" | + "int32" | + "uint32" | + "int64" | + "uint64" | + "bigint"; + + type PersistentOptions = { + name?: string; + type?: IdType; + db?: any; + }; + + export default class StorageInterface { + constructor(name: string, config: PersistentOptions); + constructor(config: string | PersistentOptions); + //mount(index: Index | Document) : Promise; + open() : Promise; + close() : Promise; + destroy() : Promise; + clear() : Promise; + db: any; + } +} diff --git a/src/db/sqlite/index.d.ts b/src/db/sqlite/index.d.ts new file mode 100644 index 0000000..070d09b --- /dev/null +++ b/src/db/sqlite/index.d.ts @@ -0,0 +1,41 @@ +declare module "flexsearch/db/sqlite" { + + type IdType = + "text" | + "char" | + "varchar" | + "string" | + "number" | + "numeric" | + "integer" | + "smallint" | + "tinyint" | + "mediumint" | + "int" | + "int8" | + "uint8" | + "int16" | + "uint16" | + "int32" | + "uint32" | + "int64" | + "uint64" | + "bigint"; + + type PersistentOptions = { + name?: string; + type?: IdType; + db?: any; + }; + + export default class StorageInterface { + constructor(name: string, config: PersistentOptions); + constructor(config: string | PersistentOptions); + //mount(index: Index | Document) : Promise; + open() : Promise; + close() : Promise; + destroy() : Promise; + clear() : Promise; + db: any; + } +} From 94fe3aa5a08b3acc677094f226241b0a049e0167 Mon Sep 17 00:00:00 2001 From: Thomas Wilkerling Date: Tue, 6 May 2025 10:22:50 +0200 Subject: [PATCH 4/6] add language presets and persistent adapter types to index.d.ts --- index.d.ts | 108 +++++++++++++++++++++++++++++++++++--------------- test/async.js | 2 +- 2 files changed, 77 insertions(+), 33 deletions(-) diff --git a/index.d.ts b/index.d.ts index 4d3fb19..0bc588c 100644 --- a/index.d.ts +++ b/index.d.ts @@ -116,6 +116,7 @@ declare module "flexsearch" { * * Language: https://github.com/nextapps-de/flexsearch#languages */ + global { type EncoderOptions = { rtl?: boolean; dedupe?: boolean; @@ -134,7 +135,7 @@ declare module "flexsearch" { minlength?: number; maxlength?: number; cache?: boolean|number; - }; + }} type EncoderSplitOptions = { letter?: boolean; @@ -152,7 +153,8 @@ declare module "flexsearch" { LatinBalance: EncoderOptions, LatinAdvanced: EncoderOptions, LatinExtra: EncoderOptions, - LatinSoundex: EncoderOptions + LatinSoundex: EncoderOptions, + CJK: EncoderOptions }; /** @@ -502,34 +504,6 @@ declare module "flexsearch" { ): Promise; } - type IdType = - "text" | - "char" | - "varchar" | - "string" | - "number" | - "numeric" | - "integer" | - "smallint" | - "tinyint" | - "mediumint" | - "int" | - "int8" | - "uint8" | - "int16" | - "uint16" | - "int32" | - "uint32" | - "int64" | - "uint64" | - "bigint"; - - type PersistentOptions = { - name?: string; - type?: IdType; - db?: any; - }; - type DefaultResolve = { query?: string; limit?: number; @@ -597,6 +571,7 @@ declare module "flexsearch" { resolve(options?: DefaultResolve): SearchResults; } + global{ class StorageInterface { constructor(name: string, config: PersistentOptions); constructor(config: string | PersistentOptions); @@ -606,7 +581,7 @@ declare module "flexsearch" { destroy() : Promise; clear() : Promise; db: any; - } + }} export class IndexedDB extends StorageInterface{ db: IDBDatabase @@ -625,7 +600,76 @@ declare module "flexsearch" { export default FlexSearch; } +// ----------------------------------- + +type IdType = + "text" | + "char" | + "varchar" | + "string" | + "number" | + "numeric" | + "integer" | + "smallint" | + "tinyint" | + "mediumint" | + "int" | + "int8" | + "uint8" | + "int16" | + "uint16" | + "int32" | + "uint32" | + "int64" | + "uint64" | + "bigint"; + +type PersistentOptions = { + name?: string; + type?: IdType; + db?: any; +}; + +declare module "flexsearch/db/redis" { + export default StorageInterface; +} + +declare module "flexsearch/db/postgres" { + export default StorageInterface; +} + +declare module "flexsearch/db/mongodb" { + export default StorageInterface; +} + +declare module "flexsearch/db/sqlite" { + export default StorageInterface; +} + +declare module "flexsearch/db/clickhouse" { + export default StorageInterface; +} + +declare module "flexsearch/db/indexeddb" { + export default class IndexedDB extends StorageInterface{ + db: IDBDatabase + } +} + +// ----------------------------------- + +declare module "flexsearch/lang/en" { + export default EncoderOptions; +} + +declare module "flexsearch/lang/de" { + export default EncoderOptions; +} + +declare module "flexsearch/lang/fr" { + export default EncoderOptions; +} + // https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html // https://github.com/futurGH/ts-to-jsdoc // https://sethmac.com/typescript-to-jsdoc/ - diff --git a/test/async.js b/test/async.js index 20cbc4f..4fa23d6 100644 --- a/test/async.js +++ b/test/async.js @@ -57,7 +57,7 @@ if(!build_light) describe("Add (Async)", function(){ if(duration) break; } - expect(duration).to.closeTo(0, 3); + expect(duration).to.closeTo(0, 4); for(let i = 0; i < 999999999; i++){ await index.addAsync(i, "foo"); From 47a6f62ceea1b2b2cca44ab05fbd95dcfa2d9707 Mon Sep 17 00:00:00 2001 From: Thomas Wilkerling Date: Tue, 6 May 2025 11:08:18 +0200 Subject: [PATCH 5/6] simplify module declaration within index.d.ts --- index.d.ts | 31 ++++--------------------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/index.d.ts b/index.d.ts index 0bc588c..30b8f48 100644 --- a/index.d.ts +++ b/index.d.ts @@ -630,23 +630,7 @@ type PersistentOptions = { db?: any; }; -declare module "flexsearch/db/redis" { - export default StorageInterface; -} - -declare module "flexsearch/db/postgres" { - export default StorageInterface; -} - -declare module "flexsearch/db/mongodb" { - export default StorageInterface; -} - -declare module "flexsearch/db/sqlite" { - export default StorageInterface; -} - -declare module "flexsearch/db/clickhouse" { +declare module "flexsearch/db/*" { export default StorageInterface; } @@ -658,16 +642,9 @@ declare module "flexsearch/db/indexeddb" { // ----------------------------------- -declare module "flexsearch/lang/en" { - export default EncoderOptions; -} - -declare module "flexsearch/lang/de" { - export default EncoderOptions; -} - -declare module "flexsearch/lang/fr" { - export default EncoderOptions; +declare module "flexsearch/lang/*" { + const Options: EncoderOptions; + export default Options; } // https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html From 5d7de9dd11dd822255a5e54b5e6157088ba2cfab Mon Sep 17 00:00:00 2001 From: Thomas Wilkerling Date: Tue, 6 May 2025 11:11:18 +0200 Subject: [PATCH 6/6] add missing type for "encoder" option to index.d.ts --- index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index 30b8f48..0697b45 100644 --- a/index.d.ts +++ b/index.d.ts @@ -193,7 +193,7 @@ declare module "flexsearch" { commit?: boolean; // Language-specific Options and Encoding - encoder?: typeof Charset | Encoders | EncoderOptions; + encoder?: typeof Charset | Encoders | EncoderOptions | Encoder; encode?: (text: string) => string[], rtl?: boolean; };