Skip to main content

create_hnsw_index_sql

Function create_hnsw_index_sql 

Source
pub fn create_hnsw_index_sql(
    table: &str,
    ops_class: &str,
    m: Option<usize>,
    ef_construction: Option<usize>,
) -> String
Expand description

Returns the CREATE INDEX statement for an HNSW index.

The operator class is chosen based on the distance metric:

  • Cosine โ†’ vector_cosine_ops
  • L2 โ†’ vector_l2_ops
  • InnerProduct โ†’ vector_ip_ops

ยงParameters

  • table: table name
  • ops_class: one of vector_cosine_ops, vector_l2_ops, vector_ip_ops
  • m: HNSW m parameter (max connections per layer). None uses the PG default (16).
  • ef_construction: HNSW build-time search width. None uses the PG default (64).