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:
Mime Čuvalo 2024-02-06 09:49:31 +00:00 committed by GitHub
parent 538734782c
commit b50cda0a6e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 64 additions and 47 deletions

View file

@ -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