Skip to content

Hybrid search — combining text and structured retrieval

Most regulatory questions don’t fit cleanly into either pure semantic search or pure database querying. “How does our SOP define a major deviation?” is a text question. “How many major deviations did we close in Q3?” is a structured-data question. “Are we meeting our SOP-defined 30-day closure target for major deviations?” is both.

Verin’s retrieval layer combines the two. We call it hybrid search: structured filters narrow the candidate pool before vector retrieval, structured queries answer count/filter/aggregate questions exactly, and citations from both layers appear side by side.

Vector search over document chunks is the right tool for “what does the policy say” questions but starts to hurt accuracy when:

  • The question needs an exact count, sum, or date — vector search returns similar passages, not aggregates
  • The question needs a filter (“only the parenteral product line” / “only Q3 of last year”) — keyword filtering on chunks is brittle; the relevant passage might not literally include the filter term
  • The question needs to cross-reference structured fields — e.g., “deviations whose CAPA effectiveness review failed” requires joining records, not text matching
  • Results need to be reproducible — re-running a vector query against a slightly updated corpus may return different chunks; structured queries are deterministic

Verin’s typed compliance records (Deviation, CAPA, batch record, validation package, training record, complaint, etc.) — produced by approved extractions — give the retrieval layer an exact-query path alongside vector search.

There are three composition patterns Verin uses depending on the question:

Structured filters narrow the candidate document set before vector search runs. Smaller candidate pool → tighter retrieval → fewer off-target citations.

“What does our SOP say about deviation closure for the parenteral product line?”

The retriever:

  1. Queries the typed Document table for category = SOP AND product = parenteral to get the relevant document IDs
  2. Runs vector search within that subset for “deviation closure”
  3. Returns passages with [D-#] citations to the filtered SOPs

Without the pre-filter, the vector search might surface SOPs from other product lines that happen to use similar language. With the pre-filter, the search is focused.

2. Structured-only for counts and aggregates

Section titled “2. Structured-only for counts and aggregates”

Some questions don’t need text retrieval at all — the answer is a number, a list, or a date. The retriever recognizes these and queries the typed records directly.

“How many major deviations did we close in Q3?”

The retriever:

  1. Queries the typed Deviation table with severity = major AND closed_at between Q3 start/end
  2. Returns the count + the list of records, citing each as [Deviation D-1234], [Deviation D-1289], …

The answer is exact. The citations are clickable into the actual records, not “somewhere in this 200-page batch summary.”

3. Combined — text plus structured in one answer

Section titled “3. Combined — text plus structured in one answer”

Many real questions need both: a policy assertion from a document, supported by a count or trend from the structured layer.

“Are we meeting our SOP-defined 30-day closure target for major deviations?”

The retriever:

  1. Vector search → SOP passage stating the 30-day target → [D-SOP-XYZ §4.2]
  2. Structured query → Q3 closure rate for major deviations: 17 of 22 within 30 days (77%) → [Deviation D-1234] … [Deviation D-1289]
  3. The answer combines both: “Your SOP-XYZ §4.2 [SOP] requires major deviations to close within 30 days. In Q3, 17 of 22 major deviations met that target (77%) — 5 closed late.”

The reader can verify the policy claim by clicking the SOP citation and the metric by clicking through to the deviation records.

Where hybrid search shows up in the product

Section titled “Where hybrid search shows up in the product”
  • Chat / copilot — applies hybrid retrieval to every question. Filtering and counting questions automatically take the structured path; narrative questions take the text path; mixed questions get both.
  • Reports — templates declare which sections are narrative (text RAG) and which are tabular (structured query). See Reports and templates.
  • Dashboards — purely structured retrieval. Trend charts, KPIs, lot-acceptance rates, CAPA effectiveness all run against typed records.
  • Regulatory monitoring — when a tracked regulation changes, the monitor uses hybrid retrieval to find affected documents (text similarity on the change description) AND affected structured records (filter on regulatory-reference fields).
  • It does not bypass per-tenant isolation. Both the document index and the structured-record tables are filtered by tenant_id on every query.
  • It is not a general-purpose ad-hoc SQL surface. The retrieval layer exposes specific structured queries that match its question types — “list all deviations in this period” works; “give me the raw join of every table in the database” doesn’t.
  • It does not replace citations. Whether the answer comes from text, structured records, or both, every claim still carries a citation that the reader can verify.
  • It is not a substitute for the regulator’s published artifact. Verin’s regulatory KB is an indexed working copy; the official source is always the regulator’s published text.