Module indexes (0.17.0)

API documentation for indexes module.

Classes

IVFIndex

IVFIndex(name: Optional[str] = None, index_type: str = 'ivf', distance_strategy: langchain_postgres.v2.indexes.DistanceStrategy = <factory>, partial_indexes: Optional[list[str]] = None, extension_name: Optional[str] = None, lists: int = 100)

IVFIndex(name: Optional[str] = None, index_type: str = 'ivf', distance_strategy: langchain_postgres.v2.indexes.DistanceStrategy =

IVFQueryOptions

IVFQueryOptions(probes: int = 1)

IVFQueryOptions(probes: int = 1)

ScaNNIndex

ScaNNIndex(name: typing.Optional[str] = None, index_type: str = 'ScaNN', distance_strategy: langchain_postgres.v2.indexes.DistanceStrategy = <factory>, partial_indexes: typing.Optional[list[str]] = None, extension_name: str = 'alloydb_scann', num_leaves: int = 5, *, mode: typing.Optional[str] = None)

ScaNN index configuration for AlloyDB.

Parameters
Name Description
num_leaves int

Number of partitions. Used when mode is None or "MANUAL"; ignored when mode="AUTO". Defaults to 5.

mode Optional[str]

Keyword-only. "AUTO" creates an automatically tuned index (the server chooses the number of leaves; the table must contain at least 10,000 rows); "MANUAL" creates a manually tuned index using num_leaves. Defaults to None, which emits the same options as previous releases.

ScaNNQueryOptions

ScaNNQueryOptions(
    num_leaves_to_search: int = 1,
    pre_reordering_num_neighbors: int = -1,
    pct_leaves_to_search: typing.Optional[float] = None,
)

Query options for ScaNN index.

Parameters
Name Description
num_leaves_to_search int

Number of leaves to search. 0 lets the server choose. Defaults to 1.

pre_reordering_num_neighbors int

Number of neighbors to return before reordering. -1 (the default) uses the server default. Must be an integer >= -1; the server enforces its own upper bound.

pct_leaves_to_search Optional[float]

Percentage (0-100, fractional values allowed) of leaves to search. When set, it is sent in addition to num_leaves_to_search; the server uses the percentage and falls back to num_leaves_to_search if the percentage resolves to zero leaves. Defaults to None (not sent).

Modules Functions

_is_int

_is_int(value: object) -> bool

True for integers (including numpy integers), excluding bools.