Regex search API
Exact text and RE2 regex search over documents, narrowed by metadata filters, with exact counts, cursors and explicit partial, timed-out and refused answers. Fixtures with expected results.
Search finds documents whose text contains what you ask for: a literal string, ignoring
case, or an RE2 regex. Metadata filters narrow
it. A document matches or it doesn't: hits come newest first, one per document, with the
matched text and the line around it. Counts are exact unless you ask for an estimate. For
results ordered by relevance to some words instead, use ranked search.
Use it when the question names something exact: an order number, an error code, a stack trace line, a product name. When the question is phrased in other words than the documents, you need vector search as well; the table at the end of this page helps you choose.
A fixture with known answers
Five synthetic support tickets. Write them, then check each query below against the IDs it
should return before you trust it with your own data. Run the blocks in order in one shell
(or one Python or TypeScript session), with a test key exported as SKIMMERDB_KEY.
B=${SKIMMERDB_URL:-https://api.skimmerdb.com/v1}
KEY=$SKIMMERDB_KEY
curl -sS $B/namespaces/support/docs -H "Authorization: Bearer $KEY" \
-H "Content-Type: application/json" -w '\n' -d '{"wait": true, "docs": [
{"id": "t-1", "text": "Refund requested for order ACME-1042", "meta": {"status": "open", "priority": 3}},
{"id": "t-2", "text": "Checkout failed with E503 after the card was charged", "meta": {"status": "open", "priority": 1}},
{"id": "t-3", "text": "Refunded order ACME-1043 after a duplicate charge", "meta": {"status": "closed", "priority": 2}},
{"id": "t-4", "text": "Order acme-1042 shipped two days late", "meta": {"status": "closed", "priority": 4}},
{"id": "t-5", "text": "Customer asked for an invoice copy", "meta": {"status": "open", "priority": 5, "order": "ACME-1042"}}]}'from skimmerdb import SkimmerDB, SkimmerDBError
db = SkimmerDB() # SKIMMERDB_KEY, and SKIMMERDB_URL if set
ns = db.namespace("support")
ns.write([
{"id": "t-1", "text": "Refund requested for order ACME-1042", "meta": {"status": "open", "priority": 3}},
{"id": "t-2", "text": "Checkout failed with E503 after the card was charged", "meta": {"status": "open", "priority": 1}},
{"id": "t-3", "text": "Refunded order ACME-1043 after a duplicate charge", "meta": {"status": "closed", "priority": 2}},
{"id": "t-4", "text": "Order acme-1042 shipped two days late", "meta": {"status": "closed", "priority": 4}},
{"id": "t-5", "text": "Customer asked for an invoice copy", "meta": {"status": "open", "priority": 5, "order": "ACME-1042"}},
], wait=True)import { SkimmerDB, SkimmerDBError } from "skimmerdb";
const db = new SkimmerDB(); // SKIMMERDB_KEY, and SKIMMERDB_URL if set
const ns = db.namespace("support");
await ns.write([
{ id: "t-1", text: "Refund requested for order ACME-1042", meta: { status: "open", priority: 3 } },
{ id: "t-2", text: "Checkout failed with E503 after the card was charged", meta: { status: "open", priority: 1 } },
{ id: "t-3", text: "Refunded order ACME-1043 after a duplicate charge", meta: { status: "closed", priority: 2 } },
{ id: "t-4", text: "Order acme-1042 shipped two days late", meta: { status: "closed", priority: 4 } },
{ id: "t-5", text: "Customer asked for an invoice copy", meta: { status: "open", priority: 5, order: "ACME-1042" } },
], { wait: true });wait: true answers once the documents are searchable. What each query should return:
| Query | Expected IDs | Why |
|---|---|---|
acme-1042 | t-4, t-1 | Plain text ignores case. t-5 has the code only in metadata, which q doesn't search |
refund | t-3, t-1 | A substring match: Refunded contains refund |
acme-1042, regex | t-4 | A regex is case-sensitive |
ACME-10[0-9]{2}, regex, status open | t-1 | t-3 matches the pattern but is closed |
E[0-9]{3}, regex, priority 1 to 3 | t-2 | |
count refund, status open | 1 |
All five come from one write, so they share a write time; within it, later documents in
docs came back first.
Search
POST /v1/namespaces/{name}/search with {"q", "regex", "filter", "limit", "cursor", "scan"},
or GET with the same query parameters (filter as JSON).
curl -sS $B/namespaces/support/search -H "Authorization: Bearer $KEY" \
-H "Content-Type: application/json" -w '\n' -d '{"q": "acme-1042"}'res = ns.search("acme-1042")
print([(h.id, h.match) for h in res.hits], res.partial)
# [('t-4', 'acme-1042'), ('t-1', 'ACME-1042')] Falseconst res = await ns.search("acme-1042");
console.log(res.hits.map((h) => [h.id, h.match]), res.partial);
// [ [ 't-4', 'acme-1042' ], [ 't-1', 'ACME-1042' ] ] falseThe answer (from a local server; times and temperature vary):
{"namespace":"support","hits":[
{"id":"t-4","match":"acme-1042","line":"Order acme-1042 shipped two days late","meta":{"status":"closed","priority":4},"written_at":"2026-10-19T19:30:36Z"},
{"id":"t-1","match":"ACME-1042","line":"Refund requested for order ACME-1042","meta":{"status":"open","priority":3},"written_at":"2026-10-19T19:30:36Z"}],
"next":"","docs":5,"took_ms":0.156,"partial":false,"temperature":"cold","store_gets":0,"store_bytes":0,"cpu_ms":0.079,"timed_out":false}Each hit has the document's id, the text that matched (match), the line it's on, the
document's meta and when it was written. Not the whole text: fetch that with
GET .../docs/{id}. docs is how many documents the namespace holds, not how many matched;
use count for that.
Exact matching
Plain text (the default) is matched literally, ignoring case:
- A substring, not a word.
refundfindsRefundandRefunded. To match a whole word, use a regex:(?i)\brefund\bfindst-1only. - No tokenising, stemming, synonyms or ranking.
refundsdoesn't findRefunded, andlate shipmentdoesn't findshipped two days late. Order is newest first, not by relevance (for that, see ranked search). - Text only.
qnever searches ids or metadata:t-5above holdsACME-1042in itsmetaand isn't a hit. Use a filter for metadata. See Data model.
curl -sS $B/namespaces/support/search -H "Authorization: Bearer $KEY" \
-H "Content-Type: application/json" -d '{"q": "refund"}' | jq -c '[.hits[].id]'
# ["t-3","t-1"]print([h.id for h in ns.search("refund").hits]) # ['t-3', 't-1']console.log((await ns.search("refund")).hits.map((h) => h.id)); // [ 't-3', 't-1' ]Ranked search (BM25)
Add "rank": "bm25" and q is read as words: the hits are the documents holding any of
them, best first by BM25 relevance, each with a
score. Rare words count for more than common ones, and a word repeated in a short document
counts for more than once in a long one.
curl -sS $B/namespaces/support/search -H "Authorization: Bearer $KEY" \
-H "Content-Type: application/json" -d '{"q": "refund for order 1042", "rank": "bm25"}' \
| jq -c '[.hits[] | {id, score: (.score*1000|round/1000), match}]'
# [{"id":"t-1","score":3.945,"match":"Refund"},{"id":"t-4","score":1.431,"match":"Order"},
# {"id":"t-5","score":0.94,"match":"for"},{"id":"t-3","score":0.516,"match":"order"}]res = ns.search("refund for order 1042", rank="bm25")
print([(h.id, round(h.score, 3)) for h in res.hits])
# [('t-1', 3.945), ('t-4', 1.431), ('t-5', 0.94), ('t-3', 0.516)]const res = await ns.search("refund for order 1042", { rank: "bm25" });
console.log(res.hits.map((h) => [h.id, Math.round(h.score! * 1000) / 1000]));
// [ [ 't-1', 3.945 ], [ 't-4', 1.431 ], [ 't-5', 0.94 ], [ 't-3', 0.516 ] ]- Words, not substrings. A word is a run of letters and digits (
ACME-1042isacmeand1042), case ignored. There's no stemming:refunddoesn't rankRefunded(t-3comes in onorder).matchandlineshow the first word that counted. - Filters narrow the ranked documents, not the statistics:
{"q": "refund for order 1042", "rank": "bm25", "filter": {"status": "open"}}givest-1thent-5, with the same scores as above. - Scores are over the namespace's current documents: a replaced or deleted document no longer counts. Compare scores within one answer, not across namespaces or over time.
- Pages:
nextworks as for any search ("r10","r20", ...). A regex can't be ranked (422), nor aqwith no words. - With a vector too, the two rankings are fused: see Vector and hybrid search.
- The first ranked query on a large namespace builds its word index (about 0.5 s for 300,000 documents); after that, a query takes a few milliseconds.
Regex
"regex": true makes q an RE2 pattern. RE2 runs in time linear in the text, so it has no
backtracking features:
- Case-sensitive unless the pattern starts with
(?i). ^and$are the start and end of the whole text, not of each line, unless the pattern starts with(?m)..doesn't match a newline unless(?s).- No backreferences or lookaround.
(a)\1,(?=...),(?!...)and(?<=...)are refused with422 invalid, and the message says which feature and where.
curl -sS $B/namespaces/support/search -H "Authorization: Bearer $KEY" \
-H "Content-Type: application/json" -d '{"q": "acme-1042", "regex": true}' | jq -c '[.hits[].id]'
# ["t-4"]
curl -sS $B/namespaces/support/search -H "Authorization: Bearer $KEY" \
-H "Content-Type: application/json" \
-d '{"q": "ACME-10[0-9]{2}", "regex": true, "filter": {"status": "open"}}' |
jq -c '[.hits[] | {id, match}]'
# [{"id":"t-1","match":"ACME-1042"}]
curl -sS $B/namespaces/support/search -H "Authorization: Bearer $KEY" \
-H "Content-Type: application/json" \
-d '{"q": "E[0-9]{3}", "regex": true, "filter": {"priority": {"gte": 1, "lt": 4}}, "limit": 50}' |
jq -c '[.hits[].id]'
# ["t-2"]
curl -sS -w ' HTTP %{http_code}\n' $B/namespaces/support/search -H "Authorization: Bearer $KEY" \
-H "Content-Type: application/json" -d '{"q": "order(?= ACME)", "regex": true}'
# {"error":"bad regex: re: lookahead (?= ...) isn't supported (it needs backtracking) (at byte 7 of the pattern)","code":"invalid"} HTTP 422print([h.id for h in ns.search("acme-1042", regex=True).hits]) # ['t-4']
res = ns.search("ACME-10[0-9]{2}", regex=True, filter={"status": "open"})
print([(h.id, h.match) for h in res.hits]) # [('t-1', 'ACME-1042')]
res = ns.search("E[0-9]{3}", regex=True, filter={"priority": {"gte": 1, "lt": 4}}, limit=50)
print([h.id for h in res.hits]) # ['t-2']
try:
ns.search("order(?= ACME)", regex=True)
except SkimmerDBError as e:
print(e.status, e.code) # 422 invalidconsole.log((await ns.search("acme-1042", { regex: true })).hits.map((h) => h.id)); // [ 't-4' ]
const open = await ns.search("ACME-10[0-9]{2}", { regex: true, filter: { status: "open" } });
console.log(open.hits.map((h) => [h.id, h.match])); // [ [ 't-1', 'ACME-1042' ] ]
const codes = await ns.search("E[0-9]{3}", { regex: true, filter: { priority: { gte: 1, lt: 4 } }, limit: 50 });
console.log(codes.hits.map((h) => h.id)); // [ 't-2' ]
try {
await ns.search("order(?= ACME)", { regex: true });
} catch (e) {
if (e instanceof SkimmerDBError) console.log(e.status, e.code); // 422 invalid
}Regexes the index can't narrow
The index finds candidates from a regex's literals (3 or more characters) and from character
classes it can look up, like [a-z][0-9]{2}[a-z]{3} or G-[A-Z0-9]{10}, so those don't read
every document. A pattern with neither, like [0-9]$, has to check every document. On a
namespace of more than 100,000 documents (or about 100 MB of them) such a query is refused
with 422 scan_refused, unless it says "scan": true; then it runs within the plan's time
limit. On a test namespace of 120,000 synthetic tickets:
curl -sS -w ' HTTP %{http_code}\n' $B/namespaces/support-archive/search \
-H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
-d '{"q": "[0-9]$", "regex": true}'{"error":"this regex has no literal of 3 or more characters the index can look up, so it would check 120000 documents one by one; add a literal (\\bcheckout[0-9]+ rather than [a-z]+[0-9]+), narrow it with a filter, or pass \"scan\": true to check them all within the plan's time limit","code":"scan_refused"} HTTP 422Adding a literal (reply 42$) or sending "scan": true makes the same namespace answer. A
count is refused the same way.
Filters
Every key in filter must hold:
{"status": "open", "priority": {"gte": 2, "lt": 5}, "team": {"ne": "api"}, "region": ["eu", "us"]}| Form | Meaning |
|---|---|
"k": value | equal |
"k": [a, b] or {"in": [a, b]} | one of |
{"ne": value} | not equal (a missing key counts as not equal) |
{"gt" | "gte" | "lt" | "lte": number} | a numeric range |
Filters apply to top-level metadata keys. Numbers compare as numbers; strings exactly. Filters prune the search before any document is read, so a selective filter over a big namespace is fast. All the rules: Filters.
Listing
An empty q lists documents, newest first, narrowed by the filter:
curl -sS $B/namespaces/support/search -H "Authorization: Bearer $KEY" \
-H "Content-Type: application/json" -d '{"q": "", "filter": {"status": "closed"}}' |
jq -c '[.hits[].id]'
# ["t-4","t-3"]print([h.id for h in ns.search("", filter={"status": "closed"}).hits]) # ['t-4', 't-3']console.log((await ns.search("", { filter: { status: "closed" } })).hits.map((h) => h.id)); // [ 't-4', 't-3' ]Pages and cursors
limit is 20 by default, at most 1,000. When there are more hits, the answer's next is a
cursor: pass it back as cursor with the same query for the next page. "" means no more.
cursor = None
ids = []
while True:
res = ns.search("acme", cursor=cursor, limit=1)
ids += [h.id for h in res.hits]
if not res.next_: # Python names the field next_
break
cursor = res.next_
print(ids) # ['t-4', 't-3', 't-1']let cursor: string | undefined;
const ids: string[] = [];
do {
const page = await ns.search("acme", { cursor, limit: 1 });
ids.push(...page.hits.map((h) => h.id));
cursor = page.next || undefined;
} while (cursor);
console.log(ids); // [ 't-4', 't-3', 't-1' ]Cursors name where a document was first written, so they stay valid while the namespace is compacted: pages go on where they left off. Documents written since appear on a new search.
Count
POST /v1/namespaces/{name}/count with {"q", "regex", "filter"} (or GET). Exact by
default: every visible document that matches, with "exact": true in the answer.
curl -sS $B/namespaces/support/count -H "Authorization: Bearer $KEY" \
-H "Content-Type: application/json" -d '{"q": "refund", "filter": {"status": "open"}}' |
jq -c '{count, exact, partial}'
# {"count":1,"exact":true,"partial":false}print(ns.count("refund", filter={"status": "open"})) # 1console.log(await ns.count("refund", { filter: { status: "open" } })); // 1On big namespaces, "exact": false estimates fast from a spread sample of the candidates
(exact when there are few; no filters). "sample": 1000 sets how many are checked (default
2,000), and lo..hi is a 95% interval for count. For grouped counts (by status, by day,
by user), use SQL.
Incomplete and refused answers
Never present a search as "everything that matches" without checking these:
| You see | Meaning | What to do |
|---|---|---|
"partial": true | Some reads failed or the query ran out of time: hits may be missing | Treat as incomplete, never as "there are no more"; retry, or say the search didn't finish |
"timed_out": true (with partial) | The search ran past the plan's time limit (10 s free, 30 s pro) and answers what it found; next goes on from the last hit | Narrow the query (a literal, a filter), or page on |
422 query_timeout | A count can't be cut short, so it fails past the time limit | Narrow it; it may pass on a warmer namespace |
422 scan_refused | A regex the index can't narrow, on a big namespace | Add a literal, or send "scan": true |
422 invalid | A bad pattern, for example a backreference or lookaround | Rewrite the pattern; don't retry unchanged |
cpu_ms in every answer is the CPU the query used. Every error code: Errors.
When you don't need vectors
| The question | Use |
|---|---|
Contains an identifier, code or exact phrase (ACME-1042, E503, a log line) | Text or regex search |
| Needs a number: how many open refunds | Count, or SQL to group |
| Asks for documents with a property (open, high priority, one product) | A filter, with q: "" |
| Is phrased in words the documents may not use ("my payment didn't go through") | Vector search, alone or narrowed by a filter |
An embedding blurs the difference between ACME-1042 and ACME-1043; a literal doesn't. A
vector query can also take q and filter, which narrow its candidates before ranking: a
required text that a relevant document doesn't contain removes it.
Warm a namespace
POST /v1/namespaces/{name}/warm with the searches you're about to run opens the namespace
(if it isn't) and fetches what those searches need, so an agent about to work on a namespace
gets warm answers from its first query. It answers the temperature before warming, what it
read and how long it took, and counts as a query.
curl -sS $B/namespaces/support/warm -H "Authorization: Bearer $KEY" \
-H "Content-Type: application/json" -d '{"queries": ["refund", "E503"]}' | jq -c '{temperature}'ns.warm(["refund", "E503"])await ns.warm(["refund", "E503"]);Next
- Quickstart: sign up, write and search in a few calls.
- Support agents: the same exact-versus-meaning choice for a help-center bot, with two tenants that share an error code.
- Keys, scopes and tenants: give each app or agent a read-only key limited to its namespaces, then check that it is refused the others.
- Performance and cost and pricing: every search and count is a query; answers report their object-storage reads and CPU.