mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 12:31:23 +00:00
Memory/QMD: prefer exact docid lookup in index
This commit is contained in:
@@ -692,9 +692,17 @@ export class QmdMemoryManager implements MemorySearchManager {
|
||||
const db = this.ensureDb();
|
||||
let row: { collection: string; path: string } | undefined;
|
||||
try {
|
||||
row = db
|
||||
.prepare("SELECT collection, path FROM documents WHERE hash LIKE ? AND active = 1 LIMIT 1")
|
||||
.get(`${normalized}%`) as { collection: string; path: string } | undefined;
|
||||
const exact = db
|
||||
.prepare("SELECT collection, path FROM documents WHERE hash = ? AND active = 1 LIMIT 1")
|
||||
.get(normalized) as { collection: string; path: string } | undefined;
|
||||
row = exact;
|
||||
if (!row) {
|
||||
row = db
|
||||
.prepare(
|
||||
"SELECT collection, path FROM documents WHERE hash LIKE ? AND active = 1 LIMIT 1",
|
||||
)
|
||||
.get(`${normalized}%`) as { collection: string; path: string } | undefined;
|
||||
}
|
||||
} catch (err) {
|
||||
if (this.isSqliteBusyError(err)) {
|
||||
log.debug(`qmd index is busy while resolving doc path: ${String(err)}`);
|
||||
|
||||
Reference in New Issue
Block a user