# find_neighbors

> **Function** in `langchain_google_vertexai`

📖 [View in docs](https://reference.langchain.com/python/langchain-google-vertexai/vectorstores/_v2_operations/find_neighbors)

Searches for neighbors in a Vertex AI Vector Search 2.0 Collection.

## Signature

```python
find_neighbors(
    project_id: str,
    region: str,
    collection_id: str,
    queries: List[List[float]],
    num_neighbors: int,
    filter_: dict | None = None,
    credentials: Optional[Credentials] = None,
    vector_field_name: str = 'embedding',
    sparse_queries: List[dict[str, List[int] | List[float]]] | None = None,
    rrf_ranking_alpha: float = 1.0,
) -> List[List[dict[str, Any]]]
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `project_id` | `str` | Yes | The GCP project ID. |
| `region` | `str` | Yes | The GCP region. |
| `collection_id` | `str` | Yes | The collection ID. |
| `queries` | `List[List[float]]` | Yes | List of query embeddings. |
| `num_neighbors` | `int` | Yes | Number of neighbors to return. |
| `filter_` | `dict \| None` | No | Optional filter dict. Examples: {"genre": {"$eq": "Drama"}},          {"$and": [{"year": {"$gte": 1990}}, {"genre": {"$eq": "Action"}}]} (default: `None`) |
| `credentials` | `Optional[Credentials]` | No | Optional credentials to use. (default: `None`) |
| `vector_field_name` | `str` | No | Name of the vector field in the collection schema. (default: `'embedding'`) |
| `sparse_queries` | `List[dict[str, List[int] \| List[float]]] \| None` | No | Optional list of sparse query embeddings for hybrid search. Each sparse query should be: {"values": [...], "indices": [...]} (default: `None`) |
| `rrf_ranking_alpha` | `float` | No | RRF ranking alpha parameter for hybrid search (0.0 to 1.0). NOTE: This parameter is currently not used in V2 API. (default: `1.0`) |

## Returns

`List[List[dict[str, Any]]]`

List of neighbor results for each query.

---

[View source on GitHub](https://github.com/langchain-ai/langchain-google/blob/a3f016b2a6c4af535df275545f76fa7424aa39e5/libs/vertexai/langchain_google_vertexai/vectorstores/_v2_operations.py#L123)