Request a demo
← All articles How it works

Retrieval in InsightRAG: metadata filters, thresholds and agents

How a question becomes an answer: which agent handles it, how vector search is narrowed by metadata, scored and de-duplicated, how the catalog turns a question into SQL, and what the model is finally given.

A RAG system answers well when it puts the right few passages in front of the model, and nothing else. Most of the engineering is in deciding what "right" means: which sources a question should search, which chunks are allowed, how strong a match has to be, and what to do about the same paragraph indexed three times. This article walks through how InsightRAG makes those decisions today.

Step 1: pick the agent

Every chat request names an agent, along with the index to search, optional metadata filters and the model to use. The streaming endpoint routes on the agent:

  • Workspace searches the chosen index, applying the metadata filters if there are any, and gives the model each chunk with its source.
  • Catalog and data search the catalog index for the tables that match the question, ask the model to write SQL for them, have the model correct the SQL so it uses only the tables and columns the catalog returned, run it on the registered connection, and answer from the rows. If the question asks for a chart, trend or insight, the answer comes back as a panel (a chart type plus its data) instead of prose.
  • Web sends the question straight to the model, with no retrieval, for general questions that the knowledge base can't answer.
  • A request named after a catalog does both: it searches the documents and runs the catalog query, then gives the model the chunks and the rows together, with an instruction to answer from that data and to say so if it is empty.

A request looks like this:

{
  "user_prompt": "What is the deductible for wind and hail on the Coastal BOP form?",
  "agent": "workspace",
  "index": "policy",
  "metadata": {"lob": "commercial-property", "category": "forms"},
  "model": "claude"
}

A workspace question restricted to commercial-property forms, answered by Claude. Values are illustrative.

Step 2: narrow the search with metadata

Vector search finds passages that are similar to the question. Similar isn't the same as relevant: a homeowners' wind exclusion is very similar to a commercial one. That's what the metadata set at ingestion is for. Retrieval accepts filters on a fixed set of fields: lob, product, category, subcategory, catalog_guid, source and source_path, file_name and fileid, type, page, created_by, user_id, and a start_date/end_date range on when the content was created. A single value is an exact match; a list matches any of its values. Unknown fields are skipped rather than failing the request.

The filters go into the search request itself (in OpenSearch, a boolean must clause next to the vector query), so a chunk outside the filter is never a candidate. That's different from searching everything and throwing results away afterwards, which can leave you with nothing when the best matches all came from the wrong place.

Step 3: score, keep the strong matches, de-duplicate

Search runs with a similarity-score threshold, so weak matches are dropped by the vector store. Of what comes back, InsightRAG keeps chunks with a score of 0.75 or more (or with no score, for stores that don't return one). Then it removes repeats: when two chunks have the same content hash, the same author and the same timestamp, which is what a message re-ingested from Slack or Teams looks like, only the first is kept. Chunks missing any of those three fields are always kept, so ordinary documents are never collapsed by accident.

Chat agents take the top five chunks after this. The standalone search API, which returns chunks rather than an answer, defaults to twenty and lets the caller choose.

Step 4: questions about tables

Some questions are not in any document. "How many open claims over $100,000 do we have in Texas?" is a database question. The catalog path handles it in four moves:

  1. Search the catalog index, which holds a description of each table (database, table name, description, connection and columns), for the tables that fit the question.
  2. Ask the model for SQL against those tables, limited to a small number of rows.
  3. Pass the query through a correction step that replaces any table or column name the catalog didn't return with the closest one it did, then run it on the connection registered for that database.
  4. Hand the rows to the model with the question, and return the tables used as the answer's sources.

In the combined path (a request named after a catalog), a query that fails is simply left out, and the model is told to reply that it was unable to fetch the information if it has no data to answer from.

Good catalogs make good answers. Text-to-SQL is only as reliable as the table and column descriptions it is given. Writing a one-line business description for each table and its key columns is the single most useful thing a data owner can do before turning the catalog agent on.

Step 5: the answer and its sources

The model is chosen per request from the integrations configured in your deployment (OpenAI, Anthropic Claude and Perplexity are included). The answer streams back as server-sent events, and the list of sources (file, page and chunk for documents, connection and tables for database answers) is sent alongside it, so the reader can check the passage or the query behind a claim.

Next: see these pieces applied to a real kind of corpus in the policy-binder use case, or tune the inputs with the chunking guide.

Tuning checklist

  • Wrong source in the answer? Add a filter, or check that the metadata was set at ingestion.
  • Nothing found? Remove the filters and ask again. If results appear, a filter value doesn't match what was loaded; if not, look at extraction.
  • The same passage three times? Check whether the copies differ in author or timestamp; only exact repeats are collapsed.
  • Wrong SQL? Improve the catalog descriptions of the tables and columns involved before anything else.

Questions people ask

Can the 0.75 cut-off be changed per request?

No. It is fixed in the retrieval code today, so tuning happens through better chunks and filters rather than a looser threshold.

Does retrieval check the reader's permissions?

Access is decided per index: the connectors read each source's permissions when content is loaded, the request's filters narrow the search, and each index is open only to the people allowed to see it. Keep content for different audiences in separate indexes.

What happens if a filter names a field that doesn't exist?

That filter is skipped and the rest of the request runs, so a typo widens the search rather than failing it. Check filter names when results look too broad.

See InsightRAG on your own sources

Tell us which sources you want to search, which model you want to run and where it has to live. We'll walk you through it.

Request a demo

Keep reading

Introduction

Introducing InsightRAG: a knowledge base built from your own sources

What InsightRAG does end to end: connectors and config-driven workflows that extract, chunk and embed your content, a vector index with metadata, and chat agents that answer from documents and databases with their sources.

November 17, 2026 · 6 min read
How it works

From a workflow to an Airflow DAG: how InsightRAG runs ingestion

Ingestion in InsightRAG is configuration, not code: a task graph becomes config.yaml, properties.yaml and a generated Airflow DAG, and each task runs on Glue, EMR or Ray. What the files contain and why it matters.

November 14, 2026 · 6 min read
How it works

Extraction and chunking: what happens to a PDF in InsightRAG

Page by page through the extractor: text or Markdown, an OCR fallback for scanned pages, an optional layout model, heading-aware splitting, tables and images saved as components, and the metadata every chunk carries.

November 11, 2026 · 6 min read