Phrase search
Search the extracted plain-text projection of every indexed HTML, PDF, and
OOXML record. The pipeline writes a texts Parquet sidecar; the
backend reads it with a bounded DuckDB columnar scan.
Pipeline
-
Index the WARC collection as for any other workflow:
metawarc index 'archives/**/*.warc*' --dbfile collection.db --resume -
Populate the
textssidecar once withindex-content --text:metawarc index-content --dbfile collection.db --textThe text-extractor chain selects
TextExtractorfor HTML,PdfTextExtractorfor PDF, andOoxmlTextExtractorfor OOXML. Each successful write becomes one row in thetextsParquet with columns(archive_id, warc_id, source, url, language, text).--textis opt-in so the default structured-extraction cost does not change. -
Search from any surface that exposes the workspace.
CLI
metawarc search "Welcome to the museum of modern art" --dbfile collection.db
metawarc search "API" --dbfile collection.db --limit 10
Each match prints one tab-separated line:
<warc_id>\t<url>\t<snippet>. The snippet is centered on the first
match and normally contains at most 256 characters; it expands when
necessary to include a phrase longer than 256 characters.
REST
curl -H "Authorization: Bearer $METAWARC_API_TOKEN" \
'http://127.0.0.1:8000/records/search?phrase=Welcome&limit=10'
GET /records/search accepts phrase (1–512 characters) and limit
(1 – METAWARC_MAX_PAGE, default 50). The response carries phrase,
limit, total, returned, and hits. total is the number of matches
in the active sidecar, while returned is the number of rows in hits.
Each hit contains archive_id, warc_id, source, url, and snippet.
MCP
search_records(phrase="Welcome to the museum of modern art", limit=50)
Returns the same counts and hits structure as the REST endpoint.
Backend
DuckDB's FTS extension regressed in 1.5.x — its create_fts_index
pragma fails to materialise the virtual index. The dependable backend
is therefore a bounded read_parquet scan with a case-insensitive
literal contains predicate. % and _ are ordinary phrase characters,
not wildcards. Results are ordered by archive_id, warc_id, source,
and url, so repeated limited searches return the same rows. No second
FTS index is created or kept in sync.
Boundaries
- Empty phrases and
limithigher than the configuredMETAWARC_MAX_PAGEare rejected. REST returns HTTP 422 for an empty query or excessive limit, and HTTP 400 for a whitespace-only phrase. - If no
textssidecar exists, the CLI exits 1 with anindex-content --texthint, REST returns HTTP 409, and MCP returns a tool error. An existing sidecar with no matches returns an emptyhitslist; the CLI prints(no matches)and exits 0. - CLI, REST, and MCP open the workspace read-only while searching.
Refresh after new WARCs
Re-running metawarc index adds them, but the texts sidecar is not
automatically rebuilt. Refresh it explicitly with --rescan:
metawarc index 'archives/**/*.warc*' --dbfile collection.db --resume
metawarc index-content --dbfile collection.db --text --rescan
See search, index-content --text,
/records/search, and the search_records
tool in Agents and MCP. For the chained
index → search workflow as a single scenario, see
Index and search.