# hybrid_search

> **Function** in `langchain_google_vertexai`

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

Performs hybrid search combining semantic and text search with RRF.

Hybrid search runs both semantic search (with auto-generated embeddings) and
text search (keyword matching) in parallel, then combines results using
Reciprocal Rank Fusion (RRF) algorithm for optimal ranking.

## Signature

```python
hybrid_search(
    project_id: str,
    region: str,
    collection_id: str,
    search_text: str,
    search_field: str,
    data_field_names: List[str],
    num_neighbors: int,
    task_type: str = 'RETRIEVAL_QUERY',
    filter_: dict | None = None,
    semantic_weight: float = 1.0,
    text_weight: float = 1.0,
    credentials: Optional[Credentials] = None,
) -> 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. |
| `search_text` | `str` | Yes | Query text used for both semantic and text search. |
| `search_field` | `str` | Yes | Name of the vector field to search (must have auto-embedding config). |
| `data_field_names` | `List[str]` | Yes | List of data field names to search in for text search. |
| `num_neighbors` | `int` | Yes | Number of neighbors to return from each search before fusion. |
| `task_type` | `str` | No | Embedding task type for semantic search. Options: "RETRIEVAL_QUERY", "RETRIEVAL_DOCUMENT", etc. (default: `'RETRIEVAL_QUERY'`) |
| `filter_` | `dict \| None` | No | Optional filter dict for semantic search only. Example: {"category": {"$eq": "Dresses"}} (default: `None`) |
| `semantic_weight` | `float` | No | Weight for semantic search results in RRF (0.0 to 1.0+). (default: `1.0`) |
| `text_weight` | `float` | No | Weight for text search results in RRF (0.0 to 1.0+). (default: `1.0`) |
| `credentials` | `Optional[Credentials]` | No | Optional credentials to use. (default: `None`) |

## Returns

`List[dict[str, Any]]`

List of search results ranked by RRF with doc_id, score, and metadata.

---

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