Skip to main content
Configure indexing using the Hierarchical Navigable Small World (HNSW) algorithm, 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

SELECT ai.create_vectorizer(
    'blog_posts'::regclass,
    indexing => ai.indexing_hnsw(min_rows => 50000, opclass => 'vector_l1_ops'),
    -- other parameters...
);

Arguments

NameTypeDefaultRequiredDescription
min_rowsint100000The minimum number of rows before creating the index
opclasstextvector_cosine_opsThe operator class for the index. Possible values are: vector_cosine_ops, vector_l1_ops, or vector_ip_ops
mint-Advanced HNSW parameters
ef_constructionint-Advanced HNSW parameters
create_when_queue_emptybooleantrueCreate the index only after all of the embeddings have been generated

Returns

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