mirror of
https://github.com/lllin000/PaperForge.git
synced 2026-07-22 17:00:23 +00:00
fix(memory): match FTS column names to papers table (authors_json, collections_json)
This commit is contained in:
parent
1acbeaae23
commit
4bb750b2db
3 changed files with 10 additions and 9 deletions
|
|
@ -148,7 +148,7 @@ def build_from_index(vault: Path) -> dict:
|
|||
|
||||
try:
|
||||
conn.execute(
|
||||
"""INSERT INTO paper_fts(rowid, zotero_key, citation_key, title, first_author, authors, abstract, journal, domain, collection_path, collection_tags)
|
||||
"""INSERT INTO paper_fts(rowid, zotero_key, citation_key, title, first_author, authors_json, abstract, journal, domain, collection_path, collections_json)
|
||||
VALUES ((SELECT rowid FROM papers WHERE zotero_key = ?), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""",
|
||||
(zotero_key, zotero_key, entry.get("citation_key", ""), entry.get("title", ""),
|
||||
entry.get("first_author", ""), paper_values.get("authors_json", ""),
|
||||
|
|
|
|||
|
|
@ -37,14 +37,15 @@ def search_papers(conn: sqlite3.Connection, query: str, limit: int = 20,
|
|||
params.append(next_step)
|
||||
|
||||
where = " AND ".join(conditions)
|
||||
# Content-sync FTS: query the FTS table directly, columns come from papers
|
||||
sql = f"""
|
||||
SELECT p.zotero_key, p.citation_key, p.title, p.year, p.doi,
|
||||
p.first_author, p.journal, p.domain, p.lifecycle,
|
||||
p.ocr_status, p.deep_reading_status, p.next_step,
|
||||
p.abstract,
|
||||
substr(p.abstract, 1, 300) as abstract,
|
||||
rank
|
||||
FROM paper_fts f
|
||||
JOIN papers p ON p.zotero_key = f.zotero_key
|
||||
JOIN papers p ON p.rowid = f.rowid
|
||||
WHERE {where}
|
||||
ORDER BY rank
|
||||
LIMIT ?
|
||||
|
|
|
|||
|
|
@ -89,12 +89,12 @@ CREATE VIRTUAL TABLE IF NOT EXISTS paper_fts USING fts5(
|
|||
citation_key,
|
||||
title,
|
||||
first_author,
|
||||
authors,
|
||||
authors_json,
|
||||
abstract,
|
||||
journal,
|
||||
domain,
|
||||
collection_path,
|
||||
collection_tags,
|
||||
collections_json,
|
||||
content='papers',
|
||||
content_rowid='rowid'
|
||||
);
|
||||
|
|
@ -102,17 +102,17 @@ CREATE VIRTUAL TABLE IF NOT EXISTS paper_fts USING fts5(
|
|||
|
||||
FTS_TRIGGERS = [
|
||||
"""CREATE TRIGGER IF NOT EXISTS papers_ai AFTER INSERT ON papers BEGIN
|
||||
INSERT INTO paper_fts(rowid, zotero_key, citation_key, title, first_author, authors, abstract, journal, domain, collection_path, collection_tags)
|
||||
INSERT INTO paper_fts(rowid, zotero_key, citation_key, title, first_author, authors_json, abstract, journal, domain, collection_path, collections_json)
|
||||
VALUES (new.rowid, new.zotero_key, new.citation_key, new.title, new.first_author, new.authors_json, new.abstract, new.journal, new.domain, new.collection_path, new.collections_json);
|
||||
END;""",
|
||||
"""CREATE TRIGGER IF NOT EXISTS papers_ad AFTER DELETE ON papers BEGIN
|
||||
INSERT INTO paper_fts(paper_fts, rowid, zotero_key, citation_key, title, first_author, authors, abstract, journal, domain, collection_path, collection_tags)
|
||||
INSERT INTO paper_fts(paper_fts, rowid, zotero_key, citation_key, title, first_author, authors_json, abstract, journal, domain, collection_path, collections_json)
|
||||
VALUES ('delete', old.rowid, old.zotero_key, old.citation_key, old.title, old.first_author, old.authors_json, old.abstract, old.journal, old.domain, old.collection_path, old.collections_json);
|
||||
END;""",
|
||||
"""CREATE TRIGGER IF NOT EXISTS papers_au AFTER UPDATE ON papers BEGIN
|
||||
INSERT INTO paper_fts(paper_fts, rowid, zotero_key, citation_key, title, first_author, authors, abstract, journal, domain, collection_path, collection_tags)
|
||||
INSERT INTO paper_fts(paper_fts, rowid, zotero_key, citation_key, title, first_author, authors_json, abstract, journal, domain, collection_path, collections_json)
|
||||
VALUES ('delete', old.rowid, old.zotero_key, old.citation_key, old.title, old.first_author, old.authors_json, old.abstract, old.journal, old.domain, old.collection_path, old.collections_json);
|
||||
INSERT INTO paper_fts(rowid, zotero_key, citation_key, title, first_author, authors, abstract, journal, domain, collection_path, collection_tags)
|
||||
INSERT INTO paper_fts(rowid, zotero_key, citation_key, title, first_author, authors_json, abstract, journal, domain, collection_path, collections_json)
|
||||
VALUES (new.rowid, new.zotero_key, new.citation_key, new.title, new.first_author, new.authors_json, new.abstract, new.journal, new.domain, new.collection_path, new.collections_json);
|
||||
END;""",
|
||||
]
|
||||
|
|
|
|||
Loading…
Reference in a new issue