Skip to content

Commit 103f617

Browse files
committed
v0.8.2
1 parent e9c26f0 commit 103f617

File tree

174 files changed

+16274
-14726
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

174 files changed

+16274
-14726
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
### Current Version
44

5+
### v0.8.2
6+
7+
- Config-Serialized Query Caches, Improved caching strategy for Document indexes and Resolver
8+
- Resolver Async Processing Workflow (including Queuing)
9+
- Extended Resolver Support: Worker, Persistent, Cache
10+
- Extended Result Highlighting: Boundaries, Ellipsis, Alignment
11+
- Improved TypeScript Typings
512
- Improved Stemmer Handling
613
- Improved Result Highlighting
714
- Use multi-language charset normalization as the default `Encoder`

README.md

Lines changed: 41 additions & 37 deletions
Large diffs are not rendered by default.

dist/db/clickhouse/index.cjs

Lines changed: 81 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -89,22 +89,22 @@ function ClickhouseDB(name, config = {}){
8989
if(!name){
9090
console.info("Default storage space was used, because a name was not passed.");
9191
}
92-
//field = "Test-456";
92+
9393
this.id = "flexsearch" + (name ? "_" + sanitize(name) : "");
9494
this.field = config.field ? "_" + sanitize(config.field) : "";
95-
// Clickhouse does not support ALTER TABLE to upgrade
96-
// the type of the ID when it is a part of the merge key
95+
96+
9797
this.type = config.type ? types[config.type.toLowerCase()] : "String";
9898
if(!this.type) throw new Error("Unknown type of ID '" + config.type + "'");
99-
//this.trx = false;
99+
100100
this.support_tag_search = true;
101101
this.db = Index || (Index = config.db || null);
102102
Object.assign(defaults, config);
103103
config.database && (defaults.config.database = config.database);
104104
this.db && delete defaults.db;
105105
}
106106
ClickhouseDB.prototype.mount = function(flexsearch){
107-
//if(flexsearch.constructor === Document){
107+
108108
if(flexsearch.index){
109109
return flexsearch.mount(this);
110110
}
@@ -141,7 +141,7 @@ ClickhouseDB.prototype.open = async function(){
141141
id ${this.type}
142142
)
143143
ENGINE = MergeTree
144-
/*PRIMARY KEY (key)*/
144+
145145
ORDER BY (key, id);
146146
`, { params: { name: this.id + ".map" + this.field }}).toPromise();
147147
break;
@@ -155,7 +155,7 @@ ClickhouseDB.prototype.open = async function(){
155155
id ${this.type}
156156
)
157157
ENGINE = MergeTree
158-
/*PRIMARY KEY (ctx, key)*/
158+
159159
ORDER BY (ctx, key, id);
160160
`).toPromise();
161161
break;
@@ -167,7 +167,7 @@ ClickhouseDB.prototype.open = async function(){
167167
id ${this.type}
168168
)
169169
ENGINE = MergeTree
170-
/*PRIMARY KEY (ctx, key)*/
170+
171171
ORDER BY (tag, id);
172172
`).toPromise();
173173
break;
@@ -198,7 +198,7 @@ ClickhouseDB.prototype.open = async function(){
198198
};
199199

200200
ClickhouseDB.prototype.close = function(){
201-
//DB && DB.close();
201+
202202
this.db = Index = null;
203203
return this;
204204
};
@@ -363,7 +363,7 @@ ClickhouseDB.prototype.has = async function(id){
363363
const result = await this.db.query(`
364364
SELECT 1
365365
FROM ${this.id}.reg
366-
WHERE id = {id:${this.type /*=== "number" ? "Int32" : "String"*/}}
366+
WHERE id = {id:${this.type }}
367367
LIMIT 1`,
368368
{ params: { id }}
369369
).toPromise();
@@ -403,7 +403,7 @@ ClickhouseDB.prototype.search = function(flexsearch, query, limit = 100, offset
403403
${ enrich ? ", doc" : "" }
404404
FROM (
405405
SELECT id, count(*) as count,
406-
${ suggest ? "SUM" : "SUM" /*"MIN"*/ }(res) as res
406+
${ suggest ? "SUM" : "SUM" }(res) as res
407407
FROM ${ this.id }.ctx${ this.field }
408408
WHERE ${ where }
409409
GROUP BY id
@@ -417,31 +417,31 @@ ClickhouseDB.prototype.search = function(flexsearch, query, limit = 100, offset
417417
${ offset ? "OFFSET " + offset : "" }
418418
`, { params }).toPromise();
419419

420-
// for(let i = 1; i < query.length; i++){
421-
// where += (where ? " UNION ALL " : "") + `
422-
// SELECT id, res
423-
// FROM ${this.id}.ctx${this.field}
424-
// WHERE ctx = {ctx${i}:String} AND key = {key${i}:String}
425-
// `;
426-
// term = query[i];
427-
// const swap = flexsearch.bidirectional && (term > keyword);
428-
// params["ctx" + i] = swap ? term : keyword;
429-
// params["key" + i] = swap ? keyword : term;
430-
// keyword = term;
431-
// }
432-
//
433-
// rows = await this.db.query(`
434-
// SELECT id, res
435-
// FROM (
436-
// SELECT id, ${suggest ? "SUM" : "MIN"}(res) as res, count(*) as count
437-
// FROM (${where}) as t
438-
// GROUP BY id
439-
// ORDER BY ${suggest ? "count DESC, res" : "res"}
440-
// LIMIT ${limit}
441-
// OFFSET ${offset}
442-
// ) as r
443-
// ${suggest ? "" : "WHERE count = " + (query.length - 1)}
444-
// `, { params }).toPromise();
420+
421+
422+
423+
424+
425+
426+
427+
428+
429+
430+
431+
432+
433+
434+
435+
436+
437+
438+
439+
440+
441+
442+
443+
444+
445445
}
446446
else {
447447

@@ -469,7 +469,7 @@ ClickhouseDB.prototype.search = function(flexsearch, query, limit = 100, offset
469469
${ enrich ? ", doc" : "" }
470470
FROM (
471471
SELECT id, count(*) as count,
472-
${ suggest ? "SUM" : "SUM" /*"MIN"*/ }(res) as res
472+
${ suggest ? "SUM" : "SUM" }(res) as res
473473
FROM ${ this.id }.map${ this.field }
474474
WHERE ${ where }
475475
GROUP BY id
@@ -483,56 +483,56 @@ ClickhouseDB.prototype.search = function(flexsearch, query, limit = 100, offset
483483
${ offset ? "OFFSET " + offset : "" }
484484
`, { params }).toPromise();
485485

486-
// for(let i = 0; i < query.length; i++){
487-
// params["key" + i] = query[i];
488-
// where += (where ? " UNION ALL " : "") + `
489-
// SELECT id, res
490-
// FROM ${ this.id }.map${ this.field }
491-
// WHERE key = {key${i}:String}
492-
// `;
493-
// }
494-
// rows = await this.db.query(`
495-
// SELECT id, res
496-
// FROM (
497-
// SELECT id, ${suggest ? "SUM" : "MIN"}(res) as res, count(*) as count
498-
// FROM (${where}) as t
499-
// GROUP BY id
500-
// ORDER BY ${suggest ? "count DESC, res" : "res"}
501-
// LIMIT ${limit}
502-
// OFFSET ${offset}
503-
// ) as r
504-
// ${ suggest ? "" : "WHERE count = " + query.length }
505-
// `, { params }).toPromise();
486+
487+
488+
489+
490+
491+
492+
493+
494+
495+
496+
497+
498+
499+
500+
501+
502+
503+
504+
505+
506506
}
507507
return rows.then(function(rows){
508508
return create_result(rows, resolve, enrich);
509509
});
510510
};
511511

512512
ClickhouseDB.prototype.info = function(){
513-
// todo
513+
514514
};
515515

516516
ClickhouseDB.prototype.transaction = function(task){
517517

518-
// not supported
518+
519519
return task.call(this);
520520
};
521521

522522
ClickhouseDB.prototype.commit = async function(flexsearch, _replace, _append){
523523

524-
// process cleanup tasks
524+
525525
if(_replace){
526526
await this.clear();
527-
// there are just removals in the task queue
527+
528528
flexsearch.commit_task = [];
529529
}
530530
else {
531531
let tasks = flexsearch.commit_task;
532532
flexsearch.commit_task = [];
533533
for(let i = 0, task; i < tasks.length; i++){
534534
task = tasks[i];
535-
// there are just removals in the task queue
535+
536536
if(task.clear){
537537
await this.clear();
538538
_replace = true;
@@ -562,7 +562,7 @@ ClickhouseDB.prototype.commit = async function(flexsearch, _replace, _append){
562562
const arr = item[1];
563563
for(let i = 0, ids; i < arr.length; i++){
564564
if((ids = arr[i]) && ids.length){
565-
//this.type || (this.type = typeof ids[0]);
565+
566566
for(let j = 0; j < ids.length; j++){
567567
data.push({
568568
key: key,
@@ -655,24 +655,24 @@ ClickhouseDB.prototype.commit = async function(flexsearch, _replace, _append){
655655
}
656656
}
657657

658-
// TODO
659-
// await this.db.insert(`INSERT INTO ${this.id}.cfg${this.field} (cfg)`, [{
660-
// cfg: JSON.stringify({
661-
// "encode": typeof flexsearch.encode === "string" ? flexsearch.encode : "",
662-
// "charset": typeof flexsearch.charset === "string" ? flexsearch.charset : "",
663-
// "tokenize": flexsearch.tokenize,
664-
// "resolution": flexsearch.resolution,
665-
// "minlength": flexsearch.minlength,
666-
// "optimize": flexsearch.optimize,
667-
// "fastupdate": flexsearch.fastupdate,
668-
// "encoder": flexsearch.encoder,
669-
// "context": {
670-
// "depth": flexsearch.depth,
671-
// "bidirectional": flexsearch.bidirectional,
672-
// "resolution": flexsearch.resolution_ctx
673-
// }
674-
// })
675-
// }]).toPromise();
658+
659+
660+
661+
662+
663+
664+
665+
666+
667+
668+
669+
670+
671+
672+
673+
674+
675+
676676

677677
promises.length && await Promise.all(promises);
678678

0 commit comments

Comments
 (0)