# HNSWIndex

> **Class** in `langchain_postgres`

📖 [View in docs](https://reference.langchain.com/python/langchain-postgres/v2/indexes/HNSWIndex)

## Signature

```python
HNSWIndex(
    self,
    name: Optional[str] = None,
    index_type: str = 'hnsw',
    distance_strategy: DistanceStrategy = (lambda: DistanceStrategy.COSINE_DISTANCE)(),
    partial_indexes: Optional[list[str]] = None,
    extension_name: Optional[str] = None,
    m: int = 16,
    ef_construction: int = 64,
)
```

## Extends

- `BaseIndex`

## Constructors

```python
__init__(
    self,
    name: Optional[str] = None,
    index_type: str = 'hnsw',
    distance_strategy: DistanceStrategy = (lambda: DistanceStrategy.COSINE_DISTANCE)(),
    partial_indexes: Optional[list[str]] = None,
    extension_name: Optional[str] = None,
    m: int = 16,
    ef_construction: int = 64,
) -> None
```

| Name | Type |
|------|------|
| `name` | `Optional[str]` |
| `index_type` | `str` |
| `distance_strategy` | `DistanceStrategy` |
| `partial_indexes` | `Optional[list[str]]` |
| `extension_name` | `Optional[str]` |
| `m` | `int` |
| `ef_construction` | `int` |


## Properties

- `index_type`
- `m`
- `ef_construction`

## Methods

- [`index_options()`](https://reference.langchain.com/python/langchain-postgres/v2/indexes/HNSWIndex/index_options)

---

[View source on GitHub](https://github.com/langchain-ai/langchain-postgres/blob/9d819182da7e3fb1b815e6c9a6b7c2cd1eb4bc0e/langchain_postgres/v2/indexes.py#L103)