search for standard sites pub-search.waow.tech
search zig blog atproto
11
fork

Configure Feed

Select the types of activity you want to include in your feed.

support tag-only search

- allow searching with just a tag (no query required)
- add tag-only SQL query in db.zig
- friendlier error message for empty search

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

zzstoatzz 32fb63d4 9b6de7a0

+19 -7
+4 -4
README.md
··· 15 15 ## api 16 16 17 17 ``` 18 - GET /search?q=<query>[&tag=<tag>] # full-text search, optional tag filter 19 - GET /tags # list all tags with counts 20 - GET /stats # document/publication counts 21 - GET /health # health check 18 + GET /search?q=<query>&tag=<tag> # search with query, tag, or both 19 + GET /tags # list all tags with counts 20 + GET /stats # document/publication counts 21 + GET /health # health check 22 22 ``` 23 23 24 24 search returns three entity types: `article` (document in a publication), `looseleaf` (standalone document), `publication` (newsletter itself)
+13 -1
backend/src/db.zig
··· 200 200 try jw.beginArray(); 201 201 202 202 // search documents (articles and looseleafs) 203 - const doc_result = if (tag_filter) |tag| 203 + const doc_result = if (query.len == 0 and tag_filter != null) 204 + // tag-only search - list documents with this tag 205 + execSql( 206 + \\SELECT d.uri, d.did, d.title, '' as snippet, 207 + \\ d.created_at, d.rkey, p.base_path, 208 + \\ CASE WHEN d.publication_uri != '' THEN 1 ELSE 0 END as has_publication 209 + \\FROM documents d 210 + \\LEFT JOIN publications p ON d.publication_uri = p.uri 211 + \\JOIN document_tags dt ON d.uri = dt.document_uri 212 + \\WHERE dt.tag = ? 213 + \\ORDER BY d.created_at DESC LIMIT 40 214 + , &.{tag_filter.?}) catch null 215 + else if (tag_filter) |tag| 204 216 execSql( 205 217 \\SELECT f.uri, d.did, d.title, 206 218 \\ snippet(documents_fts, 2, '<mark>', '</mark>', '...', 32) as snippet,
+2 -2
backend/src/http.zig
··· 65 65 const query = parseQueryParam(alloc, target, "q") catch ""; 66 66 const tag_filter = parseQueryParam(alloc, target, "tag") catch null; 67 67 68 - if (query.len == 0) { 69 - try sendJson(request, "{\"error\":\"missing q parameter\"}"); 68 + if (query.len == 0 and tag_filter == null) { 69 + try sendJson(request, "{\"error\":\"enter a search term\"}"); 70 70 return; 71 71 } 72 72