> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/cuvs/llms.txt.
> For full documentation content, see https://docs.nvidia.com/cuvs/llms-full.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/cuvs/_mcp/server.

# Ivf Flat Index Module

_Rust module: `cuvs::ivf_flat::index`_

_Source: `rust/cuvs/src/ivf_flat/index.rs`_

## Index

```rust
#[derive(Debug)]
pub struct Index(ffi::cuvsIvfFlatIndex_t);
```

Ivf-Flat ANN Index

**Methods**

| Name | Source |
| --- | --- |
| `build` | `rust/cuvs/src/ivf_flat/index.rs:25` |
| `new` | `rust/cuvs/src/ivf_flat/index.rs:39` |
| `search` | `rust/cuvs/src/ivf_flat/index.rs:56` |

### build

```rust
pub fn build<T: Into<ManagedTensor>>(
res: &Resources,
params: &IndexParams,
dataset: T,
) -> Result<Index> { ... }
```

Builds a new Index from the dataset for efficient search.

#### Arguments

* `res` - Resources to use
* `params` - Parameters for building the index
* `dataset` - A row-major matrix on either the host or device to index

_Source: `rust/cuvs/src/ivf_flat/index.rs:25`_

### new

```rust
pub fn new() -> Result<Index> { ... }
```

Creates a new empty index

_Source: `rust/cuvs/src/ivf_flat/index.rs:39`_

### search

```rust
pub fn search(
&self,
res: &Resources,
params: &SearchParams,
queries: &ManagedTensor,
neighbors: &ManagedTensor,
distances: &ManagedTensor,
) -> Result<()> { ... }
```

Perform a Approximate Nearest Neighbors search on the Index

#### Arguments

* `res` - Resources to use
* `params` - Parameters to use in searching the index
* `queries` - A matrix in device memory to query for
* `neighbors` - Matrix in device memory that receives the indices of the nearest neighbors
* `distances` - Matrix in device memory that receives the distances of the nearest neighbors

_Source: `rust/cuvs/src/ivf_flat/index.rs:56`_

_Source: `rust/cuvs/src/ivf_flat/index.rs:15`_