Skip to content

Raw natural language search poc - #3597

Open
nsantacruz wants to merge 5 commits into
masterfrom
raw-natural-language-search-poc
Open

Raw natural language search poc#3597
nsantacruz wants to merge 5 commits into
masterfrom
raw-natural-language-search-poc

Conversation

@nsantacruz

Copy link
Copy Markdown
Contributor

Description

A brief description of the PR

Code Changes

The following changes were made to the files below

Notes

Any additional notes go here

nsantacruz and others added 2 commits August 6, 2026 12:10
Disables Elasticsearch keyword search on the /search page and instead
renders results from the semantic KNN search pipeline: up to 40 direct
semantic matches followed by up to 10 link-origin matches, each tagged
with a chip. Filter sidebar and sort dropdown are hidden since they
aren't useful for this few, non-facetable results. Sheet search is
unaffected (KNN index only covers texts).

/api/knn-search is bearer-token gated for external/tool callers, so
this adds a public same-origin proxy (api/search-wrapper/semantic)
that reuses the same core search logic (KnnSearch.run_search) without
shipping the shared secret to browser JS.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
SemanticSearchQuerier set isQueryRunning but left the previous query's
hits in state, so SearchResultList kept rendering the old results
alongside the loading spinner until the new response landed -- every
search appeared to be one query behind. Reset hits on requery, matching
ElasticSearchQuerier's existing behavior.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@gitvelocity-reviewer

Copy link
Copy Markdown

📊 Code Quality Score: 30/100

Base Score 50 × ESF 0.6 = 30

Category Score Factors
🔭 Scope 13/20 9 files across backend views, URL config, and 3 frontend components + CSS + new component; new public endpoint and URL route; cross-cutting UI change affecting search rendering path
🏗️ Architecture 12/20 Clean classmethod extraction enabling reuse without duplication; new server-side proxy pattern to avoid token exposure is architecturally sound; @csrf_exempt on public LLM-calling endpoint is a design concern
⚙️ Implementation 10/20 Classmethod refactor with exception-based control flow; React component with AJAX lifecycle management including abort-on-unmount; result normalization and conditional rendering; no advanced algorithms
⚠️ Risk 10/20 New public unauthenticated endpoint calling Gemini API (cost amplification risk); @csrf_exempt removes CSRF protection; deprecated componentWillReceiveProps lifecycle; no rate limiting or feature flag
✅ Quality 3/15 No tests added for new backend endpoint, classmethod refactor, or React component; good inline docstrings on new view and classmethod; PropTypes defined; CSS is clean
🔒 Perf / Security 2/5 Token-hiding motivation correctly implemented and documented; @csrf_exempt partially undermines security posture; no rate limiting on LLM-calling endpoint

Was this score accurate? 👍 Yes · 👎 No

How this was scored →

Scored by GitVelocity · How are scores calculated?

nsantacruz and others added 3 commits August 11, 2026 13:34
The KNN search wrapper endpoint (/api/search-wrapper/semantic) did the
Gemini embedding call and pgvector KNN search synchronously in the web
request, which can be slow. It now enqueues the search as a Celery task
(semantic_search.tasks.knn_search_task) and returns a task_id; the
frontend polls the existing generic /api/async/<task_id> endpoint until
the task completes.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
autodiscover_tasks only scanned a fixed list of packages, so the
worker never imported semantic_search/tasks.py and rejected
semantic_search.knn_search as unregistered.
KnnSearch.run_search now executes inside a Celery task, but the tasks
Rollout template never injected GEMINI_API_KEY like the web pod does,
so semantic search 503'd with "Semantic search is not configured" on
any environment relying on the secret (works locally only because
local_settings.py hardcodes a key).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant