Better docs search (#4015)
Search through the keywords of an article as well as the text. This ensures that relevant examples show up for people using the search feature. ### Change Type <!-- ❗ Please select a 'Scope' label ❗️ --> - [ ] `sdk` — Changes the tldraw SDK - [ ] `dotcom` — Changes the tldraw.com web app - [x] `docs` — Changes to the documentation, examples, or templates. - [ ] `vs code` — Changes to the vscode plugin - [ ] `internal` — Does not affect user-facing stuff <!-- ❗ Please select a 'Type' label ❗️ --> - [ ] `bugfix` — Bug fix - [ ] `feature` — New feature - [x] `improvement` — Improving existing features - [ ] `chore` — Updating dependencies, other boring stuff - [ ] `galaxy brain` — Architectural changes - [ ] `tests` — Changes to any test code - [ ] `tools` — Changes to infrastructure, CI, internal scripts, debugging tools, etc. - [ ] `dunno` — I don't know ### Test Plan 1. Search for 'camera' 2. examples such as pdf annotator and image annotator now display ### Release Notes - Improves the docs search by searching through keywords
This commit is contained in:
parent
80b758d466
commit
a2ebf2984b
1 changed files with 4 additions and 3 deletions
|
@ -36,14 +36,15 @@ export async function GET(req: NextRequest) {
|
||||||
const db = await getDb()
|
const db = await getDb()
|
||||||
const searchForArticle = await db.db.prepare(
|
const searchForArticle = await db.db.prepare(
|
||||||
`
|
`
|
||||||
SELECT id, title, sectionId, categoryId, content
|
SELECT id, title, sectionId, categoryId, content, keywords
|
||||||
FROM ftsArticles
|
FROM ftsArticles
|
||||||
WHERE ftsArticles MATCH ?
|
WHERE ftsArticles MATCH ? OR keywords MATCH ?
|
||||||
ORDER BY bm25(ftsArticles, 1000.0)
|
ORDER BY bm25(ftsArticles, 1000.0)
|
||||||
`,
|
`,
|
||||||
query
|
[query, query]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
await searchForArticle.all().then(async (queryResults) => {
|
await searchForArticle.all().then(async (queryResults) => {
|
||||||
for (const article of queryResults) {
|
for (const article of queryResults) {
|
||||||
const section = await db.getSection(article.sectionId)
|
const section = await db.getSection(article.sectionId)
|
||||||
|
|
Loading…
Reference in a new issue