---
agent:
  instructions: "Use this search API to find relevant content across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://mixpeek.com/.well-known/search?q={query}"
  method: GET
  documentation: "https://mixpeek.com/llms.txt"
---

Search & Discovery

9 min read

Updated 2026-07-16

# How Do AI Agents Search Big Datasets by Navigating Clusters? (Hierarchical Cluster Search)

Flat vector search returns top-k against one query vector, which breaks down when an agent does not know the right query, the corpus is huge and diverse, or the task is exploratory. Agentic hierarchical cluster search gives the agent a map instead: a cluster hierarchy (themes -> sub-clusters -> records) it navigates coarse-to-fine, scoring its goal against a few dozen centroids and drilling into the matching branch before running a precise retrieval at the leaf. When it beats flat ANN, the navigation loop, the cost math, the honest limits, and how to build it from clustering + composite clustering + a cluster-scoped retriever.

![Ethan Steininger](/people/ethan.webp)

By [Ethan Steininger](/blog/authors/ethan), Founder & CEO, Mixpeek

Agentic Retrieval

Clustering

Hierarchical Search

Vector Search

AI Agents

Composite Clustering

[Run this on your own data. Try it as you read.Search your own archive →](https://studio.mixpeek.com/namespaces/create?mode=managed&utm_source=homepage&utm_medium=guide_cta&utm_campaign=mvs_onramp)

[One-click templatesStart from a templateEach template deploys a working search app on your own files.Browse templates](/templates)

## The Short Answer

  
  
Flat vector search answers one question: \*what are the top-k records most similar to this one query vector?\* That is exactly right for known-item lookup, and exactly wrong when an [AI agent](/guides/agentic-retrieval-how-agents-search-differently) does not yet know the right query, when the corpus is huge and heterogeneous, or when the task is exploratory ("what themes are in here," "find the outlier," "cover every category, not just the densest one"). In those cases a single flat retrieval forces the agent to guess a query and hope the top-k happens to span what it needs.  
  
**Agentic hierarchical cluster search** replaces the guess with a \*map\*. You cluster the corpus once, offline, into a hierarchy: broad themes at the top, sub-clusters beneath them, individual records at the leaves. At query time the agent navigates that map coarse-to-fine: it scores its goal against a few dozen cluster centroids (cheap), drills into the best-matching branch, and only runs a precise [feature search](/docs/retrieval/stages/overview) once it has narrowed to a leaf region. It is the difference between searching a library by re-reading every spine and searching it by walking to the right shelf first.  
  

## Flat Retrieval vs. Navigating a Hierarchy: When Each Wins

  
  
Neither is universally better. Pick by the task:  
  

Use flat vector search when...

Use hierarchical cluster search when...

You have a good query and want the closest matches ("find this product," "this exact clip")

The agent does not know the right query yet and needs to explore before it commits

The corpus is small or homogeneous

The corpus is large and diverse, and one query vector cannot span what matters

You want the single best answer

You want \*coverage\*: a representative from each theme, not ten near-duplicates of the densest one

Latency per query must be minimal and setup effort near zero

You can afford an offline clustering pass and want an interpretable, auditable search path

The task is "known-item lookup"

The task is triage, deduplication, landscape-mapping, or multi-step research

  
  
The two compose. A common agent pattern is \*navigate to localize, then retrieve to answer\*: use the hierarchy to pick the right region, then run a normal [multi-stage retriever](/guides/multi-stage-retrieval-how-agents-search-unstructured-data) scoped to that region for precise, ranked results.  
  

## What the Hierarchy Actually Is

  
  
The "map" is not magic: it is clustering output arranged in levels:  
  
*   **Level 0 (themes):** cluster your embeddings once. Each cluster is a centroid plus its members; the centroid is a compact stand-in for "everything in this theme."
*   **Deeper levels (sub-clusters):** cluster within a cluster, or run [composite clustering](/guides/composite-clustering-multi-feature-cluster-of-clusters), "clusters of clusters", to get a genuine multi-level structure where the upper level groups the centroids of the lower one.
*   **Leaves (records):** the individual documents, reachable once you have drilled into a small enough branch.
  
  
For the labels to be stable across runs (so an agent can reason about "the invoices branch" rather than "cluster 7"), promote the clusters into a [taxonomy](/guides/how-to-classify-content-against-a-taxonomy). Discovered taxonomies turn unsupervised clusters into named, navigable categories: the human- and agent-readable version of the same tree.  
  

## The Navigation Loop

  
  
The agent walks the tree coarse-to-fine. One iteration:  
  
\`\`\`text 1. Read the current level's centroids/labels (a few dozen, not millions). 2. Score the goal (or the agent's current query embedding) against each centroid. 3. Pick the best branch(es). Optionally keep 2-3 for breadth. 4. If not at a leaf: descend one level, go to step 1. 5. At a leaf region: run a precise feature\_search retriever, scoped to this branch. 6. Inspect results. If the branch was wrong, backtrack and try the runner-up. \`\`\`text  
  
The key economic property is in step 2: the agent compares its goal against **centroids**, not against every record. A million-record corpus might sort into a few hundred leaf clusters under a shallow tree, so the agent makes a few hundred comparisons across the whole descent instead of a million: and each comparison is against a summary, not raw data. Coarse-to-fine turns a linear scan into something closer to a logarithmic walk.  
  
Scoping the leaf search is the part people miss. When clustering runs, each document's cluster assignment is written back as a field on that document (the same way any [enrichment](/docs/enrichment/taxonomies) is joined onto a record). Because it is now just a payload field, a retriever's \[`attribute_filter` stage\](/docs/retrieval/filters) can restrict a normal \[`feature_search`\] to one cluster or one taxonomy branch: the same [pre-filter-then-search](/guides/filtered-vector-search-pre-post-in-place) machinery you would use for any metadata filter:  
  
\`\`\`json { "stages": \[ { "stage\_type": "attribute\_filter", "filters": \[ { "field": "cluster\_label", "operator": "eq", "value": "invoices/2026-Q2" } \] }, { "stage\_type": "feature\_search", "query": "past-due amount over 5000", "limit": 10 } \] } \`\`\`json  
  
That is the whole trick: the hierarchy localizes, the filter scopes, and the feature search ranks within the scope.  
  

## Why Agents Prefer It

  
  
*   **Cheaper at scale.** Centroid comparisons replace a full-corpus scan on the way down; the expensive vector search only runs on a pre-narrowed slice.
*   **Interpretable path.** The descent \*is\* an explanation: "themes -> finance -> overdue invoices -> these 10 records." That auditable trail is what a [retrieval explain plan](/guides/debugging-retrieval-results-rag-vector-search) gives you for flat search, except here you get it for free from the navigation.
*   **Coverage over redundancy.** Flat top-k over a lopsided corpus floods you with near-duplicates from the biggest cluster. Navigating by theme lets the agent sample \*across\* branches: the same goal as [diversity-aware retrieval](/guides/diversity-aware-retrieval-mmr-dpp), reached structurally.
*   **Fits the agent loop.** Agents already decompose, branch, and backtrack. A tree they can descend, prune, and re-enter maps onto that behavior far better than a single opaque top-k call. It is the corpus-side complement to a [retrieval control plane](/guides/retrieval-control-planes-for-ai-agents).
  
  

## Honest Limits: Read Before You Build

  
  
This is a real pattern, not a turnkey endpoint, and it is only as good as its inputs:  
  
*   **Garbage clusters, garbage map.** If the clustering is poor (wrong feature space, wrong granularity, un-normalized embeddings) the hierarchy misleads the agent. Composite and [multi-feature clustering](/guides/composite-clustering-multi-feature-cluster-of-clusters) have real normalization and per-feature-weight traps; get the clustering right first.
*   **Freshness lag.** The tree reflects the corpus \*as of the last clustering run\*. New records land in whatever cluster their embedding falls near, but the \*structure\* only updates when you re-cluster. For fast-moving data, pair this with an [incremental index-freshness](/guides/index-freshness-incremental-updates) strategy and re-cluster on a cadence.
*   **Not for known-item lookup.** If the agent already has a precise query, skip the tree: flat ANN is simpler, faster, and better. Hierarchy earns its keep on exploration and coverage, not on "find this exact thing."
*   **You compose it; Mixpeek does not ship a single "navigate" call.** Mixpeek gives you the primitives (clustering, composite clustering, discovered taxonomies, and cluster-scoped retriever filters) and you assemble the loop above in your agent. The value is that every primitive already exists and shares one data model; the architecture is yours to wire.
  
  

## How to Build It in Mixpeek

  
  
1\. **Cluster the collection.** Run clustering over the feature space that matches your task (text, image, or a [multi-feature combination](/guides/composite-clustering-multi-feature-cluster-of-clusters)). This produces centroids and writes a cluster assignment back onto each document. 2. **Add levels if you need them.** Run [composite clustering](/guides/composite-clustering-multi-feature-cluster-of-clusters) over those centroids to get a "cluster of clusters" tree, or sub-cluster the largest branches. 3. **Stabilize the labels.** Promote clusters into a [discovered taxonomy](/guides/how-to-classify-content-against-a-taxonomy) so the agent reasons over named branches, not run-specific cluster IDs. 4. **Let the agent navigate.** The agent reads centroids/labels, scores its goal, and descends: a few dozen comparisons per level. 5. **Scope the leaf retrieval.** At the chosen branch, run a [multi-stage retriever](/guides/multi-stage-retrieval-how-agents-search-unstructured-data) with an \[`attribute_filter`\](/docs/retrieval/filters) on the cluster/taxonomy field plus a `feature_search` for ranked precision. 6. **Close the loop.** Feed the descent path and outcome back as [retrieval feedback](/guides/retrieval-feedback-loops-learning-to-rank-from-interactions) so the agent learns which branches pay off.  
  
Start with the [retriever stage catalog](/docs/retrieval/stages/overview) and [taxonomies](/docs/enrichment/taxonomies); if you are still choosing where vectors live, [managed indexing](/pricing) and [bring-your-own MVS](/mvs) both support the same cluster-scoped filters.  
  

## FAQ

  
  
**How is agentic hierarchical cluster search different from flat vector search?** Flat search compares your query against the whole index and returns the top-k nearest records. Hierarchical cluster search compares your goal against a small set of cluster centroids first, descends into the best branch, and only runs a precise vector search once the region is narrow. Flat search is one hop; hierarchical is a guided walk that trades a little setup for coverage, interpretability, and cheaper search over huge, diverse corpora.  
  
**Does the agent re-cluster the data on every query?** No: and it must not. You cluster once, offline, and the agent navigates that pre-built hierarchy at query time. Clustering is the expensive, batch step; navigation is a handful of cheap centroid comparisons. Re-cluster on a cadence (or when drift is high) to keep the map fresh, but never per query.  
  
**When should I not use it?** When you have a precise, known-item query and just want the closest matches: flat ANN is simpler and faster. Also skip it when the corpus is small or homogeneous enough that one query vector already spans it, or when your clustering quality is poor: a bad hierarchy misleads the agent more than flat search would.  
  
**Is this a built-in Mixpeek feature or something I assemble?** You assemble it from primitives Mixpeek already provides: clustering and composite clustering produce the hierarchy, discovered taxonomies give stable labels, and a retriever's attribute\_filter scopes a feature search to any branch. There is no single "navigate the tree" endpoint: the navigation loop lives in your agent, and every building block it calls is a first-class part of the platform.

## Run this on your own data

Point Mixpeek at the storage you already have and search your video, images, audio, and documents the way this guide describes. Build starts at $25/mo for up to 1M vectors.

[Search your own archive](https://studio.mixpeek.com/namespaces/create?mode=managed&utm_source=homepage&utm_medium=guide_cta&utm_campaign=mvs_onramp)[Read Docs](/docs)

[Explore MVS](/mvs)[See pricing](/pricing)

## Related guides

[

Search & Discovery

### Why Does My Vector Search Return Fewer Results When I Add a Filter?

Most vector indexes find candidates first and filter afterwards, so a narrow filter leaves fewer results than you asked for, or a full page that misses the true nearest matches. How to check filtered recall on your own data, what to change in pgvector, Qdrant and Weaviate, and our own before and after numbers on 1 million vectors.

Read guide →](/guides/why-vector-search-returns-fewer-results-with-filter)[

Search & Discovery

### How Do I Let an AI Agent Look Through My Own Video Library?

To let an AI agent look through your own video library, index the videos once into searchable, timestamped segments, then give the agent a search tool it can call, usually through an MCP server. The agent asks in plain language and gets back the moments that match. This guide explains why handing the agent the files does not work, the two pieces you need, and how to connect Claude Code, Cursor, Codex or Gemini CLI.

Read guide →](/guides/how-to-let-an-ai-agent-look-through-my-video-library)[

Search & Discovery

### Why Can't My Search Find Exact Part Numbers, Codes or Names?

Semantic search compares meanings, and a part number, an error code or an unusual surname carries almost none, so the index returns records that look alike instead of the one that matches. Run a keyword (BM25) search beside the vector search, merge the two lists by rank, and use an exact filter when the identifier lives in its own field.

Read guide →](/guides/why-search-cant-find-exact-part-numbers-codes-names)