Nearest Neighbor
Functions for Vertex Vector Search.
def get_nn(embeds: list[list[float]],
filters: list[str] = [],
num_neighbors: int = number_of_neighbors) -> list[Neighbor]
Fetch nearest neighbors in vector store.
Neighbors are fetched independently for each embedding then unioned.
Args: embeds: list of embeddings to find neareast neighbors filters: category prefix to restrict results to - example 1: [‘Mens’] will only return suggestiongs with top level category ‘Mens’ - example 2: [‘Mens’, ‘Pants’] will only return suggestions with top level category ‘Mens’ and second level category ‘Pants’ num_neighbors: number of nearest neighbors to return for EACH embedding
Returns: A list of named tuples containing the the following attributes id: unique item identifier, usually used to join to a reference DB distance: the embedding distance