> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify-poc.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# indexing_hnsw

> Configure HNSW indexing for fast and accurate vector search

Configure indexing using the [Hierarchical Navigable Small World (HNSW) algorithm][hnsw-parameters], which is known for fast and accurate approximate nearest neighbor search.

HNSW is suitable for in-memory datasets and scenarios where query speed is crucial.

## Samples

```sql theme={"dark"}
SELECT ai.create_vectorizer(
    'blog_posts'::regclass,
    indexing => ai.indexing_hnsw(min_rows => 50000, opclass => 'vector_l1_ops'),
    -- other parameters...
);
```

## Arguments

| Name                       | Type    | Default             | Required | Description                                                                                                     |
| -------------------------- | ------- | ------------------- | -------- | --------------------------------------------------------------------------------------------------------------- |
| min\_rows                  | int     | 100000              | ✖        | The minimum number of rows before creating the index                                                            |
| opclass                    | text    | `vector_cosine_ops` | ✖        | The operator class for the index. Possible values are: `vector_cosine_ops`, `vector_l1_ops`, or `vector_ip_ops` |
| m                          | int     | -                   | ✖        | Advanced [HNSW parameters][hnsw-parameters]                                                                     |
| ef\_construction           | int     | -                   | ✖        | Advanced [HNSW parameters][hnsw-parameters]                                                                     |
| create\_when\_queue\_empty | boolean | true                | ✖        | Create the index only after all of the embeddings have been generated                                           |

## Returns

A JSON configuration object that you can use in `ai.create_vectorizer`.

[hnsw-parameters]: https://en.wikipedia.org/wiki/Hierarchical_navigable_small_world
