Add semantic search API endpoint (GET /notes/semantic-search) #138
No reviewers
Labels
No labels
domain:backend
domain:devops
domain:frontend
status:approved
status:in-progress
status:needs-fix
status:qa
type:bug
type:devops
type:feature
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
forgejo_admin/pal-e-api!138
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "137-semantic-search-endpoint"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Adds
GET /notes/semantic-searchendpoint that performs cosine similarity search over block embeddings using pgvector. Query text is embedded via Ollama, then matched againstblocks.embeddingusing the<=>operator with HNSW index. Returns ranked blocks with note context, content snippets, and similarity scores.Changes
src/pal_e_docs/schemas.py-- AddedSemanticSearchResultresponse model with slug, title, note_type, status, project, anchor_id, block_type, content_snippet, and similarity fieldssrc/pal_e_docs/routes/notes.py-- AddedGET /notes/semantic-searchroute mirroring thesearch_notespattern: same parameter style, raw SQL, filter logic (note_type, project, status, tags). Uses query instruction prefix for embeddings, returns 501 on SQLite, 503 on Ollama errors. Reusesextract_block_textfromembedding_workerfor content snippetstests/test_semantic_search.py-- 12 tests: 501 on SQLite, validation (empty/missing query, limit bounds), Ollama error handling (ConnectError, TimeoutException, HTTPStatusError, empty embeddings), query instruction prefix verification, model name verification, cosine operator usage, filter passthroughTest Plan
pytest tests/ -k test_semantic-- 12 tests passtest_template_rendererfailures on main)ruff checkandruff formatpass on all changed filesReview Checklist
pytest tests/ -k test_semantic)ruff check,ruff format)search_notespattern (raw SQL, same filters, same parameter style)blocks.embeddingcolumn)Closes #137Related
plan-2026-02-26-tf-modularize-postgres(traceability)Closes #137
7cbfe7bde8831d56ee38