mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-20 11:36:25 +08:00
fix(core): subscribe search not unsubscribe (#11929)
This commit is contained in:
@@ -225,17 +225,26 @@ export class FullTextInvertedIndex implements InvertedIndex {
|
||||
)?.value ?? 0;
|
||||
for (const token of queryTokens) {
|
||||
const key = InvertedIndexKey.forString(this.fieldKey, token.term);
|
||||
const objs = await trx
|
||||
.objectStore('invertedIndex')
|
||||
.index('key')
|
||||
.getAll(
|
||||
IDBKeyRange.bound(
|
||||
[this.table, key.buffer()],
|
||||
[this.table, key.add1().buffer()],
|
||||
false,
|
||||
true
|
||||
)
|
||||
);
|
||||
const objs = [
|
||||
// match exact
|
||||
await trx
|
||||
.objectStore('invertedIndex')
|
||||
.index('key')
|
||||
.get([this.table, key.buffer()]),
|
||||
// match prefix
|
||||
...(await trx
|
||||
.objectStore('invertedIndex')
|
||||
.index('key')
|
||||
.getAll(
|
||||
IDBKeyRange.bound(
|
||||
[this.table, key.buffer()],
|
||||
[this.table, key.add1().buffer()],
|
||||
true,
|
||||
true
|
||||
),
|
||||
5000 // get maximum 5000 items for prefix match
|
||||
)),
|
||||
];
|
||||
const submatched: {
|
||||
nid: number;
|
||||
score: number;
|
||||
@@ -245,6 +254,9 @@ export class FullTextInvertedIndex implements InvertedIndex {
|
||||
};
|
||||
}[] = [];
|
||||
for (const obj of objs) {
|
||||
if (!obj) {
|
||||
continue;
|
||||
}
|
||||
const key = InvertedIndexKey.fromBuffer(obj.key);
|
||||
const originTokenTerm = key.asString();
|
||||
const matchLength = token.term.length;
|
||||
|
||||
Reference in New Issue
Block a user