Retrieve in the requested language

GET /search validates the query length and language, then builds a RAG configuration from settings. rag_search embeds the query with the configured embedding provider. The repository filters translations to the same language, orders by cosine distance, and asks for the top K candidates. The default K is five; the API permits a validated override from one to fifty.

Only after the database returns those candidates does the application discard scores below RAG_MIN_SCORE, which defaults to 0.35. Because filtering happens after the top-K query, the response can contain fewer than K hits. Searching English does not search the French or Arabic rows, even if a model might place cross-language texts near each other.

query_vec = await deps.embedder.aembed_query(query)
rows = await repo.search_translations(deps.pool, query_vec, lang, top_k)
hits = [row for row in rows if float(row["score"]) >= rag.min_score]

Generate only after retrieval

When answer generation is enabled and at least one hit remains, the system formats each hit as a numbered snippet containing its title, summary, and URL. answer_messages places those snippets in the prompt and asks the model to answer only from that context, cite entries as [1], [2], and use the requested language. If there are no hits, Wassla returns no answer rather than asking the model to answer from general knowledge.

The implementation calls the chat task named summarize for this answer, so it uses the summarization model configuration and semaphore slot rather than a separate answer model. Search still returns hits when answer generation is disabled; the reader can inspect the evidence without an LLM-written synthesis.

What citations mean here

The numbered sources are a prompt convention, not a verified citation system. Wassla does not parse the generated answer to confirm that every citation number exists, that a cited snippet supports the sentence, or that the linked publisher page still contains the same information. The snippets themselves contain a URL, but the answer UI does not bind each marker to a citation object.

The retrieval unit is one whole translation row, not a passage-level chunk. Its vector represents the title, summary, and truncated body together. There is no keyword search, date filter, source filter, or reranker in the current path, and cosine similarity is a ranking signal rather than calibrated confidence. For research or high-stakes use, readers should open the source and verify the claim.

A reproducible search check

After ingesting a few records, issue the same query with different lang values and compare the returned titles and scores. This checks that the language filter and threshold behave as expected; it does not evaluate whether the answer is correct. The final note turns from query behavior to the web boundary that exposes this API and keeps ingestion out of the browser.

curl -G http://localhost:8000/search \
  --data-urlencode 'q=What happened in the election?' \
  --data-urlencode 'lang=en'