RAG with the search API

GET /v1/legal/search is a unit-level search endpoint designed to be dropped straight into a RAG pipeline: it returns individually addressable điều/khoản/điểm units with a pre-composed citation string, not whole documents you'd have to chunk yourself.

Modes

ModeCostBehavior
fts (default)1 unitPostgres full-text search over unaccented Vietnamese terms
semantic2 units, Builder+Cosine similarity over e5 embeddings
hybrid2 units, Builder+Reciprocal Rank Fusion of fts + semantic

Start with fts for exact terminology (tax code numbers, defined terms); switch to hybrid once your queries are natural-language questions rather than keywords — it consistently outranks either mode alone.

Request

curl "https://api.crawlpipe.com/v1/legal/search?q=th%E1%BB%9Di%20h%E1%BA%A1n%20n%E1%BB%99p%20thu%E1%BA%BF&mode=hybrid&eff_status=con_hieu_luc&limit=5" \
-H "Authorization: Bearer dp_live_a1b2c3d4e5f6…"

Filter on eff_status=con_hieu_luc unless your use case specifically needs superseded or not-yet-effective text — RAG answers grounded in expired law are a common and avoidable failure mode.

Building the context window

Each result's unit.content is already unit-scoped (a single khoản/điểm, or a whole điều when a document hasn't been split finer). Concatenate the top-k unit.content strings as your context, and keep unit.citation alongside each chunk:

{
  "score": 0.87,
  "unit": {
    "path": "c2.d5.k3",
    "unit_type": "khoan",
    "content": "Hóa đơn điện tử phải được lập theo định dạng chuẩn dữ liệu…",
    "citation": "Khoản 3 Điều 5 Thông tư 18/2026/TT-BTC"
  },
  "document": {
    "doc_number": "18/2026/TT-BTC",
    "eff_status": "con_hieu_luc",
    "source": { "key": "vbpl", "url": "…" }
  }
}

Citation guidance

citation is composed server-side ("Khoản 3 Điều 5 Thông tư 18/2026/TT-BTC") — paste it directly after any answer text that draws on that chunk. Don't reconstruct citations from unit.path yourself; the format may gain detail (e.g. điểm-level) without notice, but citation is contract-stable. If you need a deep link, use document.source.url.

Staying current

Search results reflect whichever revision is current at query time. If your application caches answers, subscribe to the changes feed or webhooks so a cached RAG answer gets invalidated when the underlying khoản is amended.

RAG with the search API — CrawlPipe Docs