Skip to main content

Search Guide

This guide covers how to search indexed content via the API. All examples assume you have indexed sources (see Indexing Guide) and a Bearer token.

Search documents with a query:

curl
curl -X POST http://localhost:8080/api/v1/search \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"query": "oauth callback"
}'

Response:

Response
{
"query": "oauth callback",
"mode": "hybrid",
"results": [
{
"document_id": "...",
"source_id": "...",
"title": "internal/core/services/oauth.go",
"path": "https://github.com/owner/repo/blob/main/...",
"mime_type": "text/x-go",
"snippet": "...",
"score": 0.029,
"indexed_at": "2026-04-09T11:34:26Z"
}
],
"total_count": 18,
"took": 1219665417
}

Search modes

Sercha supports three search modes:

ModeDescription
hybridBM25 text search + vector semantic search, fused with RRF (default)
textBM25 full-text search only (keyword matching)
semanticVector search only (meaning-based, requires an embedding model)

Specify a mode:

curl
curl -X POST http://localhost:8080/api/v1/search \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"query": "how does authentication work",
"mode": "text"
}'
tip

hybrid mode gives the best results when an AI provider with embeddings is configured. If no embedding model is available, Sercha falls back to text mode automatically.

Response fields

Each result contains:

FieldDescription
document_idUnique document identifier
source_idWhich source this document belongs to
titleDocument title or file path
pathURL or path to the original document
mime_typeContent type (e.g. text/x-go, text/markdown)
snippetRelevant excerpt from the document
scoreRelevance score (higher is better)
indexed_atWhen the document was last indexed

Top-level fields:

FieldDescription
queryThe query that was executed
modeThe search mode used
total_countTotal number of matching documents
tookSearch duration in nanoseconds

Search analytics

Sercha tracks search queries for analytics.

Search history shows recent queries:

curl
curl http://localhost:8080/api/v1/search/history \
-H "Authorization: Bearer $TOKEN"

Search metrics shows aggregate stats:

curl
curl http://localhost:8080/api/v1/search/metrics \
-H "Authorization: Bearer $TOKEN"