From 48e78116d76e25cee9f7b3916a1654a87fb92847 Mon Sep 17 00:00:00 2001 From: Thomas Wilkerling Date: Wed, 26 Mar 2025 19:33:16 +0100 Subject: [PATCH] refactor index.js filenames #481 --- dist/db/clickhouse/{index.cjs => db.cjs} | 0 dist/db/indexeddb/{index.js => db.cjs} | 18 +++++---- dist/db/mongodb/{index.cjs => db.cjs} | 0 dist/db/postgres/{index.cjs => db.cjs} | 0 dist/db/redis/{index.cjs => db.cjs} | 0 dist/db/sqlite/{index.cjs => db.cjs} | 0 dist/module-debug/bundle.js | 2 +- .../db/clickhouse/{index.js => db.js} | 0 .../db/indexeddb/{index.js => db.js} | 0 .../db/mongodb/{index.js => db.js} | 0 .../db/postgres/{index.js => db.js} | 0 .../module-debug/db/redis/{index.js => db.js} | 0 .../db/sqlite/{index.js => db.js} | 0 dist/module-min/bundle.js | 2 +- .../db/clickhouse/{index.js => db.js} | 0 .../db/indexeddb/{index.js => db.js} | 0 .../module-min/db/mongodb/{index.js => db.js} | 0 .../db/postgres/{index.js => db.js} | 0 dist/module-min/db/redis/{index.js => db.js} | 0 dist/module-min/db/sqlite/{index.js => db.js} | 0 dist/module/bundle.js | 2 +- dist/module/db/clickhouse/{index.js => db.js} | 0 dist/module/db/indexeddb/{index.js => db.js} | 0 dist/module/db/mongodb/{index.js => db.js} | 0 dist/module/db/postgres/{index.js => db.js} | 0 dist/module/db/redis/{index.js => db.js} | 0 dist/module/db/sqlite/{index.js => db.js} | 0 dist/node/node.mjs | 2 +- doc/persistent-clickhouse.md | 8 ++-- doc/persistent-indexeddb.md | 5 +-- doc/persistent-mongodb.md | 6 +-- doc/persistent-postgres.md | 8 ++-- doc/persistent-redis.md | 8 ++-- doc/persistent-sqlite.md | 6 +-- doc/persistent.md | 38 +++++++++++++++---- doc/worker.md | 4 +- package.json | 11 ++---- src/bundle.js | 2 +- src/db/clickhouse/{index.js => db.js} | 0 src/db/clickhouse/package.json | 2 +- src/db/indexeddb/{index.js => db.js} | 0 src/db/mongodb/{index.js => db.js} | 0 src/db/mongodb/package.json | 2 +- src/db/postgres/{index.js => db.js} | 0 src/db/postgres/package.json | 2 +- src/db/redis/{index.js => db.js} | 0 src/db/redis/package.json | 2 +- src/db/sqlite/{index.js => db.js} | 0 src/db/sqlite/package.json | 2 +- src/document/search.js | 2 +- src/worker/node.mjs | 2 +- 51 files changed, 79 insertions(+), 57 deletions(-) rename dist/db/clickhouse/{index.cjs => db.cjs} (100%) rename dist/db/indexeddb/{index.js => db.cjs} (98%) rename dist/db/mongodb/{index.cjs => db.cjs} (100%) rename dist/db/postgres/{index.cjs => db.cjs} (100%) rename dist/db/redis/{index.cjs => db.cjs} (100%) rename dist/db/sqlite/{index.cjs => db.cjs} (100%) rename dist/module-debug/db/clickhouse/{index.js => db.js} (100%) rename dist/module-debug/db/indexeddb/{index.js => db.js} (100%) rename dist/module-debug/db/mongodb/{index.js => db.js} (100%) rename dist/module-debug/db/postgres/{index.js => db.js} (100%) rename dist/module-debug/db/redis/{index.js => db.js} (100%) rename dist/module-debug/db/sqlite/{index.js => db.js} (100%) rename dist/module-min/db/clickhouse/{index.js => db.js} (100%) rename dist/module-min/db/indexeddb/{index.js => db.js} (100%) rename dist/module-min/db/mongodb/{index.js => db.js} (100%) rename dist/module-min/db/postgres/{index.js => db.js} (100%) rename dist/module-min/db/redis/{index.js => db.js} (100%) rename dist/module-min/db/sqlite/{index.js => db.js} (100%) rename dist/module/db/clickhouse/{index.js => db.js} (100%) rename dist/module/db/indexeddb/{index.js => db.js} (100%) rename dist/module/db/mongodb/{index.js => db.js} (100%) rename dist/module/db/postgres/{index.js => db.js} (100%) rename dist/module/db/redis/{index.js => db.js} (100%) rename dist/module/db/sqlite/{index.js => db.js} (100%) rename src/db/clickhouse/{index.js => db.js} (100%) rename src/db/indexeddb/{index.js => db.js} (100%) rename src/db/mongodb/{index.js => db.js} (100%) rename src/db/postgres/{index.js => db.js} (100%) rename src/db/redis/{index.js => db.js} (100%) rename src/db/sqlite/{index.js => db.js} (100%) diff --git a/dist/db/clickhouse/index.cjs b/dist/db/clickhouse/db.cjs similarity index 100% rename from dist/db/clickhouse/index.cjs rename to dist/db/clickhouse/db.cjs diff --git a/dist/db/indexeddb/index.js b/dist/db/indexeddb/db.cjs similarity index 98% rename from dist/db/indexeddb/index.js rename to dist/db/indexeddb/db.cjs index af63e6d..659524c 100644 --- a/dist/db/indexeddb/index.js +++ b/dist/db/indexeddb/db.cjs @@ -1,3 +1,5 @@ +'use strict'; + /** * @param {*} value * @param {*} default_value @@ -43,7 +45,7 @@ function sanitize(str) { return str.toLowerCase().replace(/[^a-z0-9_\-]/g, ""); } -const DB = create_object(); +const Db = create_object(); /** * @param {string|PersistentOptions=} name @@ -90,8 +92,8 @@ IdxDB.prototype.open = function(){ // return this.db = new Promise(function(resolve, reject){ - DB[self.id] || (DB[self.id] = []); - DB[self.id].push(self.field); + Db[self.id] || (Db[self.id] = []); + Db[self.id].push(self.field); const req = IndexedDB.open(self.id, VERSION); @@ -107,8 +109,8 @@ IdxDB.prototype.open = function(){ // IndexedDB is such a poor contribution :( for(let i = 0, ref; i < fields.length; i++){ ref = fields[i]; - for(let j = 0, field; j < DB[self.id].length; j++){ - field = DB[self.id][j]; + for(let j = 0, field; j < Db[self.id].length; j++){ + field = Db[self.id][j]; db.objectStoreNames.contains(ref + (ref !== "reg" ? (field ? ":" + field : "") : "")) || db.createObjectStore(ref + (ref !== "reg" ? (field ? ":" + field : "") : ""));//{ autoIncrement: true /*keyPath: "id"*/ } //.createIndex("idx", "ids", { multiEntry: true, unique: false }); @@ -193,8 +195,8 @@ IdxDB.prototype.clear = function(){ for(let i = 0, ref; i < fields.length; i++){ ref = fields[i]; - for(let j = 0, field; j < DB[this.id].length; j++){ - field = DB[this.id][j]; + for(let j = 0, field; j < Db[this.id].length; j++){ + field = Db[this.id][j]; stores.push(ref + (ref !== "reg" ? (field ? ":" + field : "") : "")); } } @@ -719,4 +721,4 @@ function promisfy(req, callback){ }); } -export { IdxDB as default }; +module.exports = IdxDB; diff --git a/dist/db/mongodb/index.cjs b/dist/db/mongodb/db.cjs similarity index 100% rename from dist/db/mongodb/index.cjs rename to dist/db/mongodb/db.cjs diff --git a/dist/db/postgres/index.cjs b/dist/db/postgres/db.cjs similarity index 100% rename from dist/db/postgres/index.cjs rename to dist/db/postgres/db.cjs diff --git a/dist/db/redis/index.cjs b/dist/db/redis/db.cjs similarity index 100% rename from dist/db/redis/index.cjs rename to dist/db/redis/db.cjs diff --git a/dist/db/sqlite/index.cjs b/dist/db/sqlite/db.cjs similarity index 100% rename from dist/db/sqlite/index.cjs rename to dist/db/sqlite/db.cjs diff --git a/dist/module-debug/bundle.js b/dist/module-debug/bundle.js index 95e5e38..9364100 100644 --- a/dist/module-debug/bundle.js +++ b/dist/module-debug/bundle.js @@ -6,7 +6,7 @@ import Index from "./index.js"; import WorkerIndex from "./worker.js"; import Resolver from "./resolver.js"; import Encoder from "./encoder.js"; -import IdxDB from "./db/indexeddb/index.js"; +import IdxDB from "./db/indexeddb/db.js"; import Charset from "./charset.js"; import { KeystoreMap, KeystoreArray, KeystoreSet } from "./keystore.js"; diff --git a/dist/module-debug/db/clickhouse/index.js b/dist/module-debug/db/clickhouse/db.js similarity index 100% rename from dist/module-debug/db/clickhouse/index.js rename to dist/module-debug/db/clickhouse/db.js diff --git a/dist/module-debug/db/indexeddb/index.js b/dist/module-debug/db/indexeddb/db.js similarity index 100% rename from dist/module-debug/db/indexeddb/index.js rename to dist/module-debug/db/indexeddb/db.js diff --git a/dist/module-debug/db/mongodb/index.js b/dist/module-debug/db/mongodb/db.js similarity index 100% rename from dist/module-debug/db/mongodb/index.js rename to dist/module-debug/db/mongodb/db.js diff --git a/dist/module-debug/db/postgres/index.js b/dist/module-debug/db/postgres/db.js similarity index 100% rename from dist/module-debug/db/postgres/index.js rename to dist/module-debug/db/postgres/db.js diff --git a/dist/module-debug/db/redis/index.js b/dist/module-debug/db/redis/db.js similarity index 100% rename from dist/module-debug/db/redis/index.js rename to dist/module-debug/db/redis/db.js diff --git a/dist/module-debug/db/sqlite/index.js b/dist/module-debug/db/sqlite/db.js similarity index 100% rename from dist/module-debug/db/sqlite/index.js rename to dist/module-debug/db/sqlite/db.js diff --git a/dist/module-min/bundle.js b/dist/module-min/bundle.js index 26f07c1..281f055 100644 --- a/dist/module-min/bundle.js +++ b/dist/module-min/bundle.js @@ -1 +1 @@ -import{SearchOptions,ContextOptions,DocumentDescriptor,DocumentSearchOptions,FieldOptions,IndexOptions,DocumentOptions,TagOptions,StoreOptions,EncoderOptions,EncoderSplitOptions,PersistentOptions,ResolverOptions}from"./type.js";import StorageInterface from"./db/interface.js";import Document from"./document.js";import Index from"./index.js";import WorkerIndex from"./worker.js";import Resolver from"./resolver.js";import Encoder from"./encoder.js";import IdxDB from"./db/indexeddb/index.js";import Charset from"./charset.js";import{KeystoreMap,KeystoreArray,KeystoreSet}from"./keystore.js";Index.prototype.add,Index.prototype.append,Index.prototype.search,Index.prototype.update,Index.prototype.remove,Index.prototype.contain,Index.prototype.clear,Index.prototype.cleanup,Index.prototype.searchCache,Index.prototype.addAsync,Index.prototype.appendAsync,Index.prototype.searchAsync,Index.prototype.updateAsync,Index.prototype.removeAsync,Index.prototype.export,Index.prototype.import,Index.prototype.serialize,Index.prototype.mount,Index.prototype.commit,Index.prototype.destroy,Index.prototype.encoder,Index.prototype.reg,Index.prototype.map,Index.prototype.ctx,Index.prototype.db,Index.prototype.tag,Index.prototype.store,Index.prototype.depth,Index.prototype.bidirectional,Index.prototype.commit_task,Index.prototype.commit_timer,Index.prototype.cache,Index.prototype.bypass,Index.prototype.document,Encoder.prototype.assign,Encoder.prototype.encode,Encoder.prototype.addMatcher,Encoder.prototype.addStemmer,Encoder.prototype.addFilter,Encoder.prototype.addMapper,Encoder.prototype.addReplacer,Document.prototype.add,Document.prototype.append,Document.prototype.search,Document.prototype.update,Document.prototype.remove,Document.prototype.contain,Document.prototype.clear,Document.prototype.cleanup,Document.prototype.addAsync,Document.prototype.appendAsync,Document.prototype.searchAsync,Document.prototype.updateAsync,Document.prototype.removeAsync,Document.prototype.mount,Document.prototype.commit,Document.prototype.destroy,Document.prototype.export,Document.prototype.import,Document.prototype.searchCache,Document.prototype.get,Document.prototype.set,Document.prototype.field,Document.prototype.index,Document.prototype.reg,Document.prototype.tag,Document.prototype.store,Document.prototype.fastupdate,Resolver.prototype.limit,Resolver.prototype.offset,Resolver.prototype.boost,Resolver.prototype.resolve,Resolver.prototype.or,Resolver.prototype.and,Resolver.prototype.xor,Resolver.prototype.not,Resolver.prototype.result,StorageInterface.db,StorageInterface.id,StorageInterface.support_tag_search,StorageInterface.fastupdate,StorageInterface.prototype.mount,StorageInterface.prototype.open,StorageInterface.prototype.close,StorageInterface.prototype.destroy,StorageInterface.prototype.clear,StorageInterface.prototype.get,StorageInterface.prototype.tag,StorageInterface.prototype.enrich,StorageInterface.prototype.has,StorageInterface.prototype.search,StorageInterface.prototype.info,StorageInterface.prototype.commit,StorageInterface.prototype.remove,KeystoreArray.length,KeystoreMap.size,KeystoreSet.size,Charset.LatinExact,Charset.LatinDefault,Charset.LatinSimple,Charset.LatinBalance,Charset.LatinAdvanced,Charset.LatinExtra,Charset.LatinSoundex,Charset.ArabicDefault,Charset.CjkDefault,Charset.CyrillicDefault,IndexOptions.preset,IndexOptions.context,IndexOptions.encoder,IndexOptions.encode,IndexOptions.resolution,IndexOptions.tokenize,IndexOptions.fastupdate,IndexOptions.score,IndexOptions.keystore,IndexOptions.rtl,IndexOptions.cache,IndexOptions.resolve,IndexOptions.db,IndexOptions.worker,IndexOptions.config,IndexOptions.priority,IndexOptions.export,IndexOptions.import,FieldOptions.preset,FieldOptions.context,FieldOptions.encoder,FieldOptions.encode,FieldOptions.resolution,FieldOptions.tokenize,FieldOptions.fastupdate,FieldOptions.score,FieldOptions.keystore,FieldOptions.rtl,FieldOptions.cache,FieldOptions.db,FieldOptions.config,FieldOptions.resolve,FieldOptions.field,FieldOptions.filter,FieldOptions.custom,FieldOptions.worker,DocumentOptions.context,DocumentOptions.encoder,DocumentOptions.encode,DocumentOptions.resolution,DocumentOptions.tokenize,DocumentOptions.fastupdate,DocumentOptions.score,DocumentOptions.keystore,DocumentOptions.rtl,DocumentOptions.cache,DocumentOptions.db,DocumentOptions.doc,DocumentOptions.document,DocumentOptions.worker,DocumentOptions.priority,DocumentOptions.export,DocumentOptions.import,ContextOptions.depth,ContextOptions.bidirectional,ContextOptions.resolution,DocumentDescriptor.field,DocumentDescriptor.index,DocumentDescriptor.tag,DocumentDescriptor.store,DocumentDescriptor.id,TagOptions.field,TagOptions.tag,TagOptions.filter,TagOptions.custom,TagOptions.keystore,TagOptions.db,TagOptions.config,StoreOptions.field,StoreOptions.filter,StoreOptions.custom,StoreOptions.config,SearchOptions.query,SearchOptions.limit,SearchOptions.offset,SearchOptions.context,SearchOptions.suggest,SearchOptions.resolve,SearchOptions.enrich,SearchOptions.resolution,DocumentSearchOptions.query,DocumentSearchOptions.limit,DocumentSearchOptions.offset,DocumentSearchOptions.context,DocumentSearchOptions.suggest,DocumentSearchOptions.enrich,DocumentSearchOptions.tag,DocumentSearchOptions.field,DocumentSearchOptions.index,DocumentSearchOptions.pluck,DocumentSearchOptions.merge,DocumentSearchOptions.highlight,EncoderOptions.rtl,EncoderOptions.dedupe,EncoderOptions.split,EncoderOptions.include,EncoderOptions.exclude,EncoderOptions.prepare,EncoderOptions.finalize,EncoderOptions.filter,EncoderOptions.matcher,EncoderOptions.mapper,EncoderOptions.stemmer,EncoderOptions.replacer,EncoderOptions.minlength,EncoderOptions.maxlength,EncoderOptions.cache,EncoderSplitOptions.letter,EncoderSplitOptions.number,EncoderSplitOptions.symbol,EncoderSplitOptions.punctuation,EncoderSplitOptions.control,EncoderSplitOptions.char,PersistentOptions.name,PersistentOptions.field,PersistentOptions.type,PersistentOptions.db,ResolverOptions.index,ResolverOptions.query,ResolverOptions.limit,ResolverOptions.offset,ResolverOptions.enrich,ResolverOptions.resolve,ResolverOptions.suggest,ResolverOptions.and,ResolverOptions.or,ResolverOptions.xor,ResolverOptions.not;const FlexSearch={Index:Index,Charset:Charset,Encoder:Encoder,Document:Document,Worker:WorkerIndex,Resolver:Resolver,IndexedDB:IdxDB,Language:{}};{const a="undefined"==typeof self?"undefined"==typeof global?self:global:self;let b;(b=a.define)&&b.amd?b([],function(){return FlexSearch}):"object"==typeof a.exports?a.exports=FlexSearch:a.FlexSearch=FlexSearch}export default FlexSearch;export{Index,Document,Encoder,Charset,WorkerIndex as Worker,Resolver,IdxDB as IndexedDB}; \ No newline at end of file +import{SearchOptions,ContextOptions,DocumentDescriptor,DocumentSearchOptions,FieldOptions,IndexOptions,DocumentOptions,TagOptions,StoreOptions,EncoderOptions,EncoderSplitOptions,PersistentOptions,ResolverOptions}from"./type.js";import StorageInterface from"./db/interface.js";import Document from"./document.js";import Index from"./index.js";import WorkerIndex from"./worker.js";import Resolver from"./resolver.js";import Encoder from"./encoder.js";import IdxDB from"./db/indexeddb/db.js";import Charset from"./charset.js";import{KeystoreMap,KeystoreArray,KeystoreSet}from"./keystore.js";Index.prototype.add,Index.prototype.append,Index.prototype.search,Index.prototype.update,Index.prototype.remove,Index.prototype.contain,Index.prototype.clear,Index.prototype.cleanup,Index.prototype.searchCache,Index.prototype.addAsync,Index.prototype.appendAsync,Index.prototype.searchAsync,Index.prototype.updateAsync,Index.prototype.removeAsync,Index.prototype.export,Index.prototype.import,Index.prototype.serialize,Index.prototype.mount,Index.prototype.commit,Index.prototype.destroy,Index.prototype.encoder,Index.prototype.reg,Index.prototype.map,Index.prototype.ctx,Index.prototype.db,Index.prototype.tag,Index.prototype.store,Index.prototype.depth,Index.prototype.bidirectional,Index.prototype.commit_task,Index.prototype.commit_timer,Index.prototype.cache,Index.prototype.bypass,Index.prototype.document,Encoder.prototype.assign,Encoder.prototype.encode,Encoder.prototype.addMatcher,Encoder.prototype.addStemmer,Encoder.prototype.addFilter,Encoder.prototype.addMapper,Encoder.prototype.addReplacer,Document.prototype.add,Document.prototype.append,Document.prototype.search,Document.prototype.update,Document.prototype.remove,Document.prototype.contain,Document.prototype.clear,Document.prototype.cleanup,Document.prototype.addAsync,Document.prototype.appendAsync,Document.prototype.searchAsync,Document.prototype.updateAsync,Document.prototype.removeAsync,Document.prototype.mount,Document.prototype.commit,Document.prototype.destroy,Document.prototype.export,Document.prototype.import,Document.prototype.searchCache,Document.prototype.get,Document.prototype.set,Document.prototype.field,Document.prototype.index,Document.prototype.reg,Document.prototype.tag,Document.prototype.store,Document.prototype.fastupdate,Resolver.prototype.limit,Resolver.prototype.offset,Resolver.prototype.boost,Resolver.prototype.resolve,Resolver.prototype.or,Resolver.prototype.and,Resolver.prototype.xor,Resolver.prototype.not,Resolver.prototype.result,StorageInterface.db,StorageInterface.id,StorageInterface.support_tag_search,StorageInterface.fastupdate,StorageInterface.prototype.mount,StorageInterface.prototype.open,StorageInterface.prototype.close,StorageInterface.prototype.destroy,StorageInterface.prototype.clear,StorageInterface.prototype.get,StorageInterface.prototype.tag,StorageInterface.prototype.enrich,StorageInterface.prototype.has,StorageInterface.prototype.search,StorageInterface.prototype.info,StorageInterface.prototype.commit,StorageInterface.prototype.remove,KeystoreArray.length,KeystoreMap.size,KeystoreSet.size,Charset.LatinExact,Charset.LatinDefault,Charset.LatinSimple,Charset.LatinBalance,Charset.LatinAdvanced,Charset.LatinExtra,Charset.LatinSoundex,Charset.ArabicDefault,Charset.CjkDefault,Charset.CyrillicDefault,IndexOptions.preset,IndexOptions.context,IndexOptions.encoder,IndexOptions.encode,IndexOptions.resolution,IndexOptions.tokenize,IndexOptions.fastupdate,IndexOptions.score,IndexOptions.keystore,IndexOptions.rtl,IndexOptions.cache,IndexOptions.resolve,IndexOptions.db,IndexOptions.worker,IndexOptions.config,IndexOptions.priority,IndexOptions.export,IndexOptions.import,FieldOptions.preset,FieldOptions.context,FieldOptions.encoder,FieldOptions.encode,FieldOptions.resolution,FieldOptions.tokenize,FieldOptions.fastupdate,FieldOptions.score,FieldOptions.keystore,FieldOptions.rtl,FieldOptions.cache,FieldOptions.db,FieldOptions.config,FieldOptions.resolve,FieldOptions.field,FieldOptions.filter,FieldOptions.custom,FieldOptions.worker,DocumentOptions.context,DocumentOptions.encoder,DocumentOptions.encode,DocumentOptions.resolution,DocumentOptions.tokenize,DocumentOptions.fastupdate,DocumentOptions.score,DocumentOptions.keystore,DocumentOptions.rtl,DocumentOptions.cache,DocumentOptions.db,DocumentOptions.doc,DocumentOptions.document,DocumentOptions.worker,DocumentOptions.priority,DocumentOptions.export,DocumentOptions.import,ContextOptions.depth,ContextOptions.bidirectional,ContextOptions.resolution,DocumentDescriptor.field,DocumentDescriptor.index,DocumentDescriptor.tag,DocumentDescriptor.store,DocumentDescriptor.id,TagOptions.field,TagOptions.tag,TagOptions.filter,TagOptions.custom,TagOptions.keystore,TagOptions.db,TagOptions.config,StoreOptions.field,StoreOptions.filter,StoreOptions.custom,StoreOptions.config,SearchOptions.query,SearchOptions.limit,SearchOptions.offset,SearchOptions.context,SearchOptions.suggest,SearchOptions.resolve,SearchOptions.enrich,SearchOptions.resolution,DocumentSearchOptions.query,DocumentSearchOptions.limit,DocumentSearchOptions.offset,DocumentSearchOptions.context,DocumentSearchOptions.suggest,DocumentSearchOptions.enrich,DocumentSearchOptions.tag,DocumentSearchOptions.field,DocumentSearchOptions.index,DocumentSearchOptions.pluck,DocumentSearchOptions.merge,DocumentSearchOptions.highlight,EncoderOptions.rtl,EncoderOptions.dedupe,EncoderOptions.split,EncoderOptions.include,EncoderOptions.exclude,EncoderOptions.prepare,EncoderOptions.finalize,EncoderOptions.filter,EncoderOptions.matcher,EncoderOptions.mapper,EncoderOptions.stemmer,EncoderOptions.replacer,EncoderOptions.minlength,EncoderOptions.maxlength,EncoderOptions.cache,EncoderSplitOptions.letter,EncoderSplitOptions.number,EncoderSplitOptions.symbol,EncoderSplitOptions.punctuation,EncoderSplitOptions.control,EncoderSplitOptions.char,PersistentOptions.name,PersistentOptions.field,PersistentOptions.type,PersistentOptions.db,ResolverOptions.index,ResolverOptions.query,ResolverOptions.limit,ResolverOptions.offset,ResolverOptions.enrich,ResolverOptions.resolve,ResolverOptions.suggest,ResolverOptions.and,ResolverOptions.or,ResolverOptions.xor,ResolverOptions.not;const FlexSearch={Index:Index,Charset:Charset,Encoder:Encoder,Document:Document,Worker:WorkerIndex,Resolver:Resolver,IndexedDB:IdxDB,Language:{}};{const a="undefined"==typeof self?"undefined"==typeof global?self:global:self;let b;(b=a.define)&&b.amd?b([],function(){return FlexSearch}):"object"==typeof a.exports?a.exports=FlexSearch:a.FlexSearch=FlexSearch}export default FlexSearch;export{Index,Document,Encoder,Charset,WorkerIndex as Worker,Resolver,IdxDB as IndexedDB}; \ No newline at end of file diff --git a/dist/module-min/db/clickhouse/index.js b/dist/module-min/db/clickhouse/db.js similarity index 100% rename from dist/module-min/db/clickhouse/index.js rename to dist/module-min/db/clickhouse/db.js diff --git a/dist/module-min/db/indexeddb/index.js b/dist/module-min/db/indexeddb/db.js similarity index 100% rename from dist/module-min/db/indexeddb/index.js rename to dist/module-min/db/indexeddb/db.js diff --git a/dist/module-min/db/mongodb/index.js b/dist/module-min/db/mongodb/db.js similarity index 100% rename from dist/module-min/db/mongodb/index.js rename to dist/module-min/db/mongodb/db.js diff --git a/dist/module-min/db/postgres/index.js b/dist/module-min/db/postgres/db.js similarity index 100% rename from dist/module-min/db/postgres/index.js rename to dist/module-min/db/postgres/db.js diff --git a/dist/module-min/db/redis/index.js b/dist/module-min/db/redis/db.js similarity index 100% rename from dist/module-min/db/redis/index.js rename to dist/module-min/db/redis/db.js diff --git a/dist/module-min/db/sqlite/index.js b/dist/module-min/db/sqlite/db.js similarity index 100% rename from dist/module-min/db/sqlite/index.js rename to dist/module-min/db/sqlite/db.js diff --git a/dist/module/bundle.js b/dist/module/bundle.js index 95e5e38..9364100 100644 --- a/dist/module/bundle.js +++ b/dist/module/bundle.js @@ -6,7 +6,7 @@ import Index from "./index.js"; import WorkerIndex from "./worker.js"; import Resolver from "./resolver.js"; import Encoder from "./encoder.js"; -import IdxDB from "./db/indexeddb/index.js"; +import IdxDB from "./db/indexeddb/db.js"; import Charset from "./charset.js"; import { KeystoreMap, KeystoreArray, KeystoreSet } from "./keystore.js"; diff --git a/dist/module/db/clickhouse/index.js b/dist/module/db/clickhouse/db.js similarity index 100% rename from dist/module/db/clickhouse/index.js rename to dist/module/db/clickhouse/db.js diff --git a/dist/module/db/indexeddb/index.js b/dist/module/db/indexeddb/db.js similarity index 100% rename from dist/module/db/indexeddb/index.js rename to dist/module/db/indexeddb/db.js diff --git a/dist/module/db/mongodb/index.js b/dist/module/db/mongodb/db.js similarity index 100% rename from dist/module/db/mongodb/index.js rename to dist/module/db/mongodb/db.js diff --git a/dist/module/db/postgres/index.js b/dist/module/db/postgres/db.js similarity index 100% rename from dist/module/db/postgres/index.js rename to dist/module/db/postgres/db.js diff --git a/dist/module/db/redis/index.js b/dist/module/db/redis/db.js similarity index 100% rename from dist/module/db/redis/index.js rename to dist/module/db/redis/db.js diff --git a/dist/module/db/sqlite/index.js b/dist/module/db/sqlite/db.js similarity index 100% rename from dist/module/db/sqlite/index.js rename to dist/module/db/sqlite/db.js diff --git a/dist/node/node.mjs b/dist/node/node.mjs index ccdb210..11b90d9 100644 --- a/dist/node/node.mjs +++ b/dist/node/node.mjs @@ -7,7 +7,7 @@ import { join } from "path"; // Test Path //import Index from "../../src/index.js"; //import { Index } from "../../dist/flexsearch.bundle.module.min.js"; -import { Index } from "flexsearch/esm"; +import { Index } from "flexsearch"; /** @type Index */ let index; diff --git a/doc/persistent-clickhouse.md b/doc/persistent-clickhouse.md index deaf9bf..e72cdff 100644 --- a/doc/persistent-clickhouse.md +++ b/doc/persistent-clickhouse.md @@ -10,8 +10,8 @@ npm install clickhouse@2.6.0 Create an index and assign a Clickhouse storage adapter to it by using `index.mount(db)`: ```js -import Index from "./index.js"; -import Database from "./db/clickhouse/index.js"; +import { Index } from "flexsearch"; +import Database from "flexsearch/db/clickhouse"; // your database configuration const config = { @@ -50,7 +50,7 @@ Pass a valid `clickhouse` instance on creation: ```js import { ClickHouse } from "clickhouse"; -import Database from "./db/clickhouse/index.js"; +import Database from "flexsearch/db/clickhouse"; // assume you've created a custom database instance... const database = new ClickHouse({/* config */}); // pass database instance as option @@ -68,7 +68,7 @@ The Clickhouse driver does not properly support upgrading a merge key by ALTER T You will save required disk space and also gain performance when define a numeric ID type explicitly. ```js -import Database from "./db/clickhouse/index.js"; +import Database from "flexsearch/db/clickhouse"; // force integer type const db = new Database("my-store", { type: "integer" diff --git a/doc/persistent-indexeddb.md b/doc/persistent-indexeddb.md index 9677e6c..7fe43ab 100644 --- a/doc/persistent-indexeddb.md +++ b/doc/persistent-indexeddb.md @@ -5,12 +5,11 @@ IndexedDB is a persistent storage supported by all major browsers. Create an index and assign a IndexedDB storage adapter to it by using `index.mount(db)`: ```js -import Index from "./index.js"; -import Database from "./db/indexeddb/index.js"; +import { Index, IndexedDB } from "../dist/flexsearch.bundle.module.min.js"; // create an index const index = new Index(); // create db instance with optional namespace -const db = new Database("my-store"); +const db = new IndexedDB("my-store"); // mount and await before transfering data await index.mount(db); diff --git a/doc/persistent-mongodb.md b/doc/persistent-mongodb.md index 624dab7..b38a28c 100644 --- a/doc/persistent-mongodb.md +++ b/doc/persistent-mongodb.md @@ -10,8 +10,8 @@ npm install mongodb@6.13.0 Create an index and assign a MongoDB storage adapter to it by using `index.mount(db)`: ```js -import Index from "./index.js"; -import Database from "./db/mongodb/index.js"; +import { Index } from "flexsearch"; +import Database from "flexsearch/db/mongodb"; // create an index const index = new Index(); // create db instance with optional namespace @@ -40,7 +40,7 @@ Pass a valid `mongodb` instance on creation: ```js import { MongoClient } from "mongodb"; -import Database from "./db/mongodb/index.js"; +import Database from "flexsearch/db/mongodb"; // assume you've created a custom database instance... const database = new MongoClient("mongodb://localhost:27017/"); // connect and await diff --git a/doc/persistent-postgres.md b/doc/persistent-postgres.md index 2de2354..c8bb403 100644 --- a/doc/persistent-postgres.md +++ b/doc/persistent-postgres.md @@ -10,8 +10,8 @@ npm install pg-promise@11.10.2 Create an index and assign a Postgres storage adapter to it by using `index.mount(db)`: ```js -import Index from "./index.js"; -import Database from "./db/postgres/index.js"; +import { Index } from "flexsearch"; +import Database from "flexsearch/db/postgres"; // your database configuration const config = { @@ -51,7 +51,7 @@ Pass a valid `pg-promise` instance on creation: ```js import pg_promise from "pg-promise"; -import Database from "./db/postgres/index.js"; +import Database from "flexsearch/db/postgres"; const pgp = pg_promise(); // assume you've created a custom database instance... const database = pgp(`postgres://${user}:${pass}@${host}:${port}/${name}`); @@ -70,7 +70,7 @@ Once the type was upgraded, you'll need to re-create the index to switch back. When you data content is including numeric strings (eg. for ID "15712") then defining the type will automatically cast into the right type: ```js -import Database from "./db/postgres/index.js"; +import Database from "flexsearch/db/postgres"; // force integer type const db = new Database("my-store", { type: "integer" diff --git a/doc/persistent-redis.md b/doc/persistent-redis.md index b4fe5c9..9b83c92 100644 --- a/doc/persistent-redis.md +++ b/doc/persistent-redis.md @@ -10,8 +10,8 @@ npm install redis@4.7.0 Create an index and assign a Redis storage adapter to it by using `index.mount(db)`: ```js -import Index from "./index.js"; -import Database from "./db/redis/index.js"; +import { Index } from "flexsearch"; +import Database from "flexsearch/db/redis"; // Redis Connection const config = { @@ -49,7 +49,7 @@ Pass a valid `redis` instance on creation: ```js import { createClient } from "redis"; -import Database from "./db/redis/index.js"; +import Database from "flexsearch/db/redis"; // assume you've created a custom redis instance... const redis = await createClient("redis://localhost:6379").connect(); // pass instance as option @@ -64,7 +64,7 @@ Since Redis stores everything as Strings, you'll need to define the type of ID. Also when your data content includes numeric strings (eg. "15712"), defining a type will automatically cast IDs into your choice: ```js -import Database from "./db/redis/index.js"; +import Database from "flexsearch/db/redis"; // force integer type const db = new Database("my-store", { type: "integer" diff --git a/doc/persistent-sqlite.md b/doc/persistent-sqlite.md index c4ea44a..67db4c6 100644 --- a/doc/persistent-sqlite.md +++ b/doc/persistent-sqlite.md @@ -10,8 +10,8 @@ npm install sqlite3@5.1.7 Create an index and assign a SQLite storage adapter to it by using `index.mount(db)`: ```js -import Index from "./index.js"; -import Database from "./db/sqlite/index.js"; +import { Index } from "flexsearch"; +import Database from "flexsearch/db/sqlite"; // create an index const index = new Index(); @@ -55,7 +55,7 @@ Pass a valid `sqlite3` instance on creation: ```js import sqlite3 from "sqlite3"; -import Database from "./db/sqlite/index.js"; +import Database from "flexsearch/db/sqlite"; // assume you've created a custom database instance... const database = new sqlite3.Database("./path-to-db/main.db"); diff --git a/doc/persistent.md b/doc/persistent.md index 3e2266f..57edc65 100644 --- a/doc/persistent.md +++ b/doc/persistent.md @@ -1,4 +1,4 @@ -## Persistent Indexes +# Persistent Indexes FlexSearch provides a new Storage Adapter where indexes are delegated through persistent storages. @@ -49,15 +49,16 @@ Examples Browser: - [basic-persistent](../example/browser-module/basic-persistent) - [document-persistent](../example/browser-module/document-persistent) +## Browser (IndexedDB) + ```js -import FlexSearchIndex from "./index.d.ts"; -import Database from "./db/indexeddb/index.js"; +import { Index, IndexedDB } from "../dist/flexsearch.bundle.module.min.js"; // create an index -const index = new FlexSearchIndex(); +const index = new Index(); // create db instance with optional prefix -const db = new Database("my-store"); +const db = new IndexedDB("my-store"); // mount and await before transfering data -await flexsearch.mount(db); +await index.mount(db); // update the index as usual index.add(1, "content..."); @@ -108,7 +109,30 @@ await index.commit(); You can call the commit method manually also when `commit: true` option was set. -### Benchmark +## Node.js + +```js +import { Index } from "flexsearch"; +import Database from "flexsearch/db/postgres"; +// create an index +const index = new Index(); +// create db instance with optional prefix +const db = new Database("my-store"); +// mount and await before transfering data +await index.mount(db); + +// update the index as usual +index.add(1, "content..."); +index.update(2, "content..."); +index.remove(3); + +// changes are automatically committed by default +// when you need to wait for the task completion, then you +// can use the commit method explicitely: +await index.commit(); +``` + +## Benchmark The benchmark was measured in "terms per second". diff --git a/doc/worker.md b/doc/worker.md index 260848e..e001ad2 100644 --- a/doc/worker.md +++ b/doc/worker.md @@ -178,7 +178,7 @@ export default { Create your index by assigning the configuration file from above: ```js -import { Worker as WorkerIndex } from "flexsearch/esm"; +import { Worker as WorkerIndex } from "flexsearch"; const index = await new WorkerIndex(config); // add data to the index // ... @@ -261,7 +261,7 @@ export default { Create your index by assigning the configuration file from above: ```js -import { Document } from "flexsearch/esm"; +import { Document } from "flexsearch"; const document = await new Document(config); // add data to the index // ... diff --git a/package.json b/package.json index a9a856e..638e472 100644 --- a/package.json +++ b/package.json @@ -41,19 +41,16 @@ "require": "./dist/lang/*.min.js" }, "./db/*": { - "import": "./dist/module/db/*/index.js", - "require": "./dist/db/*/index.cjs" + "import": "./dist/module/db/*/db.js", + "require": "./dist/db/*/db.cjs" }, "./debug": { "import": "./dist/flexsearch.bundle.module.debug.js", "require": "./dist/flexsearch.bundle.debug.js" - }, - "./esm": "./dist/flexsearch.bundle.module.min.js", - "./esm/lang/*": "./dist/module/lang/*.js" + } }, "browser": { "flexsearch": "./dist/flexsearch.bundle.module.min.js", - "flexsearch/esm": "./dist/flexsearch.bundle.module.min.js", "flexsearch/debug": "./dist/flexsearch.bundle.module.debug.js", "dist/flexsearch.bundle.min.js": "./dist/flexsearch.bundle.min.js", "dist/flexsearch.bundle.module.min.js": "./dist/flexsearch.bundle.module.min.js", @@ -76,7 +73,7 @@ "build:es5": "node task/build RELEASE=es5 DEBUG=false PROFILER=false SUPPORT_WORKER=true SUPPORT_ENCODER=true SUPPORT_CHARSET=true SUPPORT_CACHE=true SUPPORT_ASYNC=true SUPPORT_STORE=true SUPPORT_TAGS=true SUPPORT_SUGGESTION=true SUPPORT_SERIALIZE=true SUPPORT_DOCUMENT=true POLYFILL=true SUPPORT_PERSISTENT=true SUPPORT_RESOLVER=true SUPPORT_KEYSTORE=true SUPPORT_COMPRESSION=false LANGUAGE_OUT=ECMASCRIPT5_STRICT", "build:es5:debug": "node task/build RELEASE=es5 DEBUG=true PROFILER=false SUPPORT_WORKER=true SUPPORT_ENCODER=true SUPPORT_CHARSET=true SUPPORT_CACHE=true SUPPORT_ASYNC=true SUPPORT_STORE=true SUPPORT_TAGS=true SUPPORT_SUGGESTION=true SUPPORT_SERIALIZE=true SUPPORT_DOCUMENT=true POLYFILL=true SUPPORT_PERSISTENT=true SUPPORT_RESOLVER=true SUPPORT_KEYSTORE=true SUPPORT_COMPRESSION=false FORMATTING=PRETTY_PRINT LANGUAGE_OUT=ECMASCRIPT5_STRICT", "build:lang": "node task/build RELEASE=lang", - "build:db": "npx rollup tmp/db/indexeddb/index.js --file dist/db/indexeddb/index.js --format es && npx rollup tmp/db/postgres/index.js --file dist/db/postgres/index.cjs --format cjs && npx rollup tmp/db/sqlite/index.js --file dist/db/sqlite/index.cjs --format cjs && npx rollup tmp/db/mongodb/index.js --file dist/db/mongodb/index.cjs --format cjs && npx rollup tmp/db/redis/index.js --file dist/db/redis/index.cjs --format cjs && npx rollup tmp/db/clickhouse/index.js --file dist/db/clickhouse/index.cjs --format cjs", + "build:db": "npx rollup tmp/db/indexeddb/db.js --file dist/db/indexeddb/db.cjs --format cjs && npx rollup tmp/db/postgres/db.js --file dist/db/postgres/db.cjs --format cjs && npx rollup tmp/db/sqlite/db.js --file dist/db/sqlite/db.cjs --format cjs && npx rollup tmp/db/mongodb/db.js --file dist/db/mongodb/db.cjs --format cjs && npx rollup tmp/db/redis/db.js --file dist/db/redis/db.cjs --format cjs && npx rollup tmp/db/clickhouse/db.js --file dist/db/clickhouse/db.cjs --format cjs", "build:module": "node task/babel && exit 0", "build:module:debug": "node task/babel DEBUG=true && exit 0", "build:module:min": "node task/babel RELEASE=min && exit 0", diff --git a/src/bundle.js b/src/bundle.js index 7f72476..0cdd059 100644 --- a/src/bundle.js +++ b/src/bundle.js @@ -31,7 +31,7 @@ import Index from "./index.js"; import WorkerIndex from "./worker.js"; import Resolver from "./resolver.js"; import Encoder from "./encoder.js"; -import IdxDB from "./db/indexeddb/index.js"; +import IdxDB from "./db/indexeddb/db.js"; import Charset from "./charset.js"; import { KeystoreMap, KeystoreArray, KeystoreSet } from "./keystore.js"; diff --git a/src/db/clickhouse/index.js b/src/db/clickhouse/db.js similarity index 100% rename from src/db/clickhouse/index.js rename to src/db/clickhouse/db.js diff --git a/src/db/clickhouse/package.json b/src/db/clickhouse/package.json index 0a25556..da81e64 100644 --- a/src/db/clickhouse/package.json +++ b/src/db/clickhouse/package.json @@ -3,7 +3,7 @@ "preferGlobal": false, "name": "flexsearch-clickhouse", "version": "0.1.0", - "main": "index.js", + "main": "db.js", "dependencies": { "clickhouse": "^2.6.0" } diff --git a/src/db/indexeddb/index.js b/src/db/indexeddb/db.js similarity index 100% rename from src/db/indexeddb/index.js rename to src/db/indexeddb/db.js diff --git a/src/db/mongodb/index.js b/src/db/mongodb/db.js similarity index 100% rename from src/db/mongodb/index.js rename to src/db/mongodb/db.js diff --git a/src/db/mongodb/package.json b/src/db/mongodb/package.json index 7b8a20d..3842248 100644 --- a/src/db/mongodb/package.json +++ b/src/db/mongodb/package.json @@ -3,7 +3,7 @@ "preferGlobal": false, "name": "flexsearch-mongodb", "version": "0.1.0", - "main": "index.js", + "main": "db.js", "dependencies": { "mongodb": "^6.13.0" } diff --git a/src/db/postgres/index.js b/src/db/postgres/db.js similarity index 100% rename from src/db/postgres/index.js rename to src/db/postgres/db.js diff --git a/src/db/postgres/package.json b/src/db/postgres/package.json index 77492ee..6680183 100644 --- a/src/db/postgres/package.json +++ b/src/db/postgres/package.json @@ -3,7 +3,7 @@ "preferGlobal": false, "name": "flexsearch-postgres", "version": "0.1.0", - "main": "index.js", + "main": "db.js", "dependencies": { "pg-promise": "^11.10.2" } diff --git a/src/db/redis/index.js b/src/db/redis/db.js similarity index 100% rename from src/db/redis/index.js rename to src/db/redis/db.js diff --git a/src/db/redis/package.json b/src/db/redis/package.json index 1ae1c71..6b5cadb 100644 --- a/src/db/redis/package.json +++ b/src/db/redis/package.json @@ -3,7 +3,7 @@ "preferGlobal": false, "name": "flexsearch-redis", "version": "0.1.0", - "main": "index.js", + "main": "db.js", "dependencies": { "redis": "^4.7.0" } diff --git a/src/db/sqlite/index.js b/src/db/sqlite/db.js similarity index 100% rename from src/db/sqlite/index.js rename to src/db/sqlite/db.js diff --git a/src/db/sqlite/package.json b/src/db/sqlite/package.json index 7364563..e1d276d 100644 --- a/src/db/sqlite/package.json +++ b/src/db/sqlite/package.json @@ -3,7 +3,7 @@ "preferGlobal": false, "name": "flexsearch-sqlite", "version": "0.1.0", - "main": "index.js", + "main": "db.js", "dependencies": { "sqlite3": "^5.1.7" } diff --git a/src/document/search.js b/src/document/search.js index 86b7afa..1f0c393 100644 --- a/src/document/search.js +++ b/src/document/search.js @@ -569,7 +569,7 @@ function highlight_fields(result, query, index, field, tree, template, limit, of } } - res[j].highlight = str; + res[j]["highlight"] = str; } } diff --git a/src/worker/node.mjs b/src/worker/node.mjs index ccdb210..11b90d9 100644 --- a/src/worker/node.mjs +++ b/src/worker/node.mjs @@ -7,7 +7,7 @@ import { join } from "path"; // Test Path //import Index from "../../src/index.js"; //import { Index } from "../../dist/flexsearch.bundle.module.min.js"; -import { Index } from "flexsearch/esm"; +import { Index } from "flexsearch"; /** @type Index */ let index;