docs: add full-text search (#2735)
### Change Type - [x] `patch` — Bug fix ### Test Plan 1. Make sure search (AI and regular) still works as expected. ### Release Notes - Docs: Add full-text search.
This commit is contained in:
parent
538734782c
commit
b50cda0a6e
7 changed files with 64 additions and 47 deletions
|
@ -119,6 +119,22 @@ export async function addContentToDb(
|
|||
}
|
||||
}
|
||||
|
||||
export async function addFTS(db: Database<sqlite3.Database, sqlite3.Statement>) {
|
||||
await db.run(`DROP TABLE IF EXISTS ftsArticles`)
|
||||
await db.run(
|
||||
`CREATE VIRTUAL TABLE ftsArticles USING fts5(title, content, description, keywords, id, sectionId, categoryId, tokenize="trigram")`
|
||||
)
|
||||
await db.run(
|
||||
`INSERT INTO ftsArticles SELECT title, content, description, keywords, id, sectionId, categoryId FROM articles;`
|
||||
)
|
||||
|
||||
await db.run(`DROP TABLE IF EXISTS ftsHeadings`)
|
||||
await db.run(
|
||||
`CREATE VIRTUAL TABLE ftsHeadings USING fts5(title, slug, id, articleId, tokenize="trigram")`
|
||||
)
|
||||
await db.run(`INSERT INTO ftsHeadings SELECT title, slug, id, articleId FROM headings;`)
|
||||
}
|
||||
|
||||
const slugs = new GithubSlugger()
|
||||
|
||||
const MATCH_HEADINGS = /(?:^|\n)(#{1,6})\s+(.+?)(?=\n|$)/g
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue