Skip to Content
Developers
GuideCore Concepts

Hybrid Search & Keyset Cursors

Qwen3-4B dense embeddings + PostgreSQL FTS fused via RRF, forum/statute filters, and three-state totals.

Open Markdown

POST /api/v1/in/cases/search (2 credits, scope corpus:read) executes a hybrid retrieval pipeline across 130,979 rulings from the Supreme Court of India, High Courts, and 12 tribunals.

How Retrieval Works

  1. Dense Vector Search: Queries are embedded into 2,560-dimensional Qwen3-4B vectors and searched via pgvector.
  2. Full-Text Search (FTS): PostgreSQL legal-lexicon FTS matches exact statute citations, party names, and statutory phrases.
  3. Reciprocal Rank Fusion (RRF): Ranked lists from dense vector and FTS channels are fused into a unified relevance score.

Filtering & Inline Intelligence

  • forum_type: "supreme_court" | "high_court" | "tribunal"
  • court_codes: Array of canonical court or tribunal codes from GET /api/v1/in/courts (e.g. ["SC", "NCLAT"]).
  • statute_codes: Filter to rulings referencing specific Central Acts (e.g. ["IPC", "NI_ACT"]).
  • year_from / year_to: Inclusive decision year window.
  • include_intelligence: When true, embeds pre-extracted ratio_decidendi and key_findings directly inside CaseSearchItem at no extra credit cost.

Opaque Cursors & Three-State Totals

Both POST /api/v1/in/cases/search and GET /api/v1/in/cases use opaque base64url keyset cursors (next_cursor, has_more) instead of expensive OFFSET queries:

  • total_is_exact: false with total: null: Vidhi avoids slow COUNT(*) full scans on filtered corpus queries.
  • Keep iterating while has_more === true by passing cursor: response.next_cursor.
  • All items[].id values are string-encoded BIGINT identifiers ("122965").

On this page