# AzureCosmosDBNoSqlVectorSearch

> **Class** in `langchain_azure_cosmosdb`

📖 [View in docs](https://reference.langchain.com/python/langchain-azure-cosmosdb/_vectorstore/AzureCosmosDBNoSqlVectorSearch)

`Azure Cosmos DB for NoSQL` vector store.

To use, you should have both:
    - the ``azure-cosmos`` python package installed

You can read more about vector search, full text search
and hybrid search using AzureCosmosDBNoSQL here:
https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/vector-search
https://learn.microsoft.com/en-us/azure/cosmos-db/gen-ai/full-text-search
https://learn.microsoft.com/en-us/azure/cosmos-db/gen-ai/hybrid-search

## Signature

```python
AzureCosmosDBNoSqlVectorSearch(
    self,
    *,
    cosmos_client: CosmosClient,
    embedding: Embeddings,
    vector_embedding_policy: Dict[str, Any],
    indexing_policy: Dict[str, Any],
    cosmos_container_properties: Dict[str, Any],
    cosmos_database_properties: Dict[str, Any],
    full_text_policy: Optional[Dict[str, Any]] = None,
    vector_search_fields: Dict[str, Any],
    database_name: str = 'vectorSearchDB',
    container_name: str = 'vectorSearchContainer',
    search_type: str = 'vector',
    metadata_key: str = 'metadata',
    create_container: bool = True,
    full_text_search_enabled: bool = False,
    table_alias: str = 'c',
    request_charge_callback: Optional[CosmosDBRequestChargeCallback] = None,
)
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `cosmos_client` | `CosmosClient` | Yes | Client used to connect to azure cosmosdb no sql account. |
| `database_name` | `str` | No | Name of the database to be created. (default: `'vectorSearchDB'`) |
| `container_name` | `str` | No | Name of the container to be created. (default: `'vectorSearchContainer'`) |
| `embedding` | `Embeddings` | Yes | Text embedding model to use. |
| `vector_embedding_policy` | `Dict[str, Any]` | Yes | Vector Embedding Policy for the container. |
| `full_text_policy` | `Optional[Dict[str, Any]]` | No | Full Text Policy for the container. (default: `None`) |
| `indexing_policy` | `Dict[str, Any]` | Yes | Indexing Policy for the container. |
| `cosmos_container_properties` | `Dict[str, Any]` | Yes | Container Properties for the container. |
| `cosmos_database_properties` | `Dict[str, Any]` | Yes | Database Properties for the container. |
| `vector_search_fields` | `Dict[str, Any]` | Yes | Vector Search and Text                   Search Fields for the container. |
| `search_type` | `str` | No | CosmosDB Search Type to be performed. (default: `'vector'`) |
| `metadata_key` | `str` | No | Metadata key to use for data schema. (default: `'metadata'`) |
| `create_container` | `bool` | No | Set to true if the container does not exist. (default: `True`) |
| `full_text_search_enabled` | `bool` | No | Set to true if the full text search is enabled. (default: `False`) |
| `table_alias` | `str` | No | Alias for the table to use in the WHERE clause. (default: `'c'`) |
| `request_charge_callback` | `Optional[CosmosDBRequestChargeCallback]` | No | Optional callback invoked with the request charge aggregated across all requests in a logical operation. (default: `None`) |

## Extends

- `VectorStore`

## Constructors

```python
__init__(
    self,
    *,
    cosmos_client: CosmosClient,
    embedding: Embeddings,
    vector_embedding_policy: Dict[str, Any],
    indexing_policy: Dict[str, Any],
    cosmos_container_properties: Dict[str, Any],
    cosmos_database_properties: Dict[str, Any],
    full_text_policy: Optional[Dict[str, Any]] = None,
    vector_search_fields: Dict[str, Any],
    database_name: str = 'vectorSearchDB',
    container_name: str = 'vectorSearchContainer',
    search_type: str = 'vector',
    metadata_key: str = 'metadata',
    create_container: bool = True,
    full_text_search_enabled: bool = False,
    table_alias: str = 'c',
    request_charge_callback: Optional[CosmosDBRequestChargeCallback] = None,
) -> None
```

| Name | Type |
|------|------|
| `cosmos_client` | `CosmosClient` |
| `embedding` | `Embeddings` |
| `vector_embedding_policy` | `Dict[str, Any]` |
| `indexing_policy` | `Dict[str, Any]` |
| `cosmos_container_properties` | `Dict[str, Any]` |
| `cosmos_database_properties` | `Dict[str, Any]` |
| `full_text_policy` | `Optional[Dict[str, Any]]` |
| `vector_search_fields` | `Dict[str, Any]` |
| `database_name` | `str` |
| `container_name` | `str` |
| `search_type` | `str` |
| `metadata_key` | `str` |
| `create_container` | `bool` |
| `full_text_search_enabled` | `bool` |
| `table_alias` | `str` |
| `request_charge_callback` | `Optional[CosmosDBRequestChargeCallback]` |


## Properties

- `VALID_SEARCH_TYPES`
- `embeddings`

## Methods

- [`close()`](https://reference.langchain.com/python/langchain-azure-cosmosdb/_vectorstore/AzureCosmosDBNoSqlVectorSearch/close)
- [`add_texts()`](https://reference.langchain.com/python/langchain-azure-cosmosdb/_vectorstore/AzureCosmosDBNoSqlVectorSearch/add_texts)
- [`from_texts()`](https://reference.langchain.com/python/langchain-azure-cosmosdb/_vectorstore/AzureCosmosDBNoSqlVectorSearch/from_texts)
- [`from_connection_string_and_aad()`](https://reference.langchain.com/python/langchain-azure-cosmosdb/_vectorstore/AzureCosmosDBNoSqlVectorSearch/from_connection_string_and_aad)
- [`from_connection_string_and_key()`](https://reference.langchain.com/python/langchain-azure-cosmosdb/_vectorstore/AzureCosmosDBNoSqlVectorSearch/from_connection_string_and_key)
- [`delete()`](https://reference.langchain.com/python/langchain-azure-cosmosdb/_vectorstore/AzureCosmosDBNoSqlVectorSearch/delete)
- [`delete_document_by_id()`](https://reference.langchain.com/python/langchain-azure-cosmosdb/_vectorstore/AzureCosmosDBNoSqlVectorSearch/delete_document_by_id)
- [`similarity_search()`](https://reference.langchain.com/python/langchain-azure-cosmosdb/_vectorstore/AzureCosmosDBNoSqlVectorSearch/similarity_search)
- [`similarity_search_with_score()`](https://reference.langchain.com/python/langchain-azure-cosmosdb/_vectorstore/AzureCosmosDBNoSqlVectorSearch/similarity_search_with_score)
- [`similarity_search_by_vector()`](https://reference.langchain.com/python/langchain-azure-cosmosdb/_vectorstore/AzureCosmosDBNoSqlVectorSearch/similarity_search_by_vector)
- [`max_marginal_relevance_search_by_vector()`](https://reference.langchain.com/python/langchain-azure-cosmosdb/_vectorstore/AzureCosmosDBNoSqlVectorSearch/max_marginal_relevance_search_by_vector)
- [`max_marginal_relevance_search()`](https://reference.langchain.com/python/langchain-azure-cosmosdb/_vectorstore/AzureCosmosDBNoSqlVectorSearch/max_marginal_relevance_search)
- [`vector_search_with_score()`](https://reference.langchain.com/python/langchain-azure-cosmosdb/_vectorstore/AzureCosmosDBNoSqlVectorSearch/vector_search_with_score)
- [`vector_search_with_threshold()`](https://reference.langchain.com/python/langchain-azure-cosmosdb/_vectorstore/AzureCosmosDBNoSqlVectorSearch/vector_search_with_threshold)
- [`full_text_search()`](https://reference.langchain.com/python/langchain-azure-cosmosdb/_vectorstore/AzureCosmosDBNoSqlVectorSearch/full_text_search)
- [`full_text_ranking()`](https://reference.langchain.com/python/langchain-azure-cosmosdb/_vectorstore/AzureCosmosDBNoSqlVectorSearch/full_text_ranking)
- [`hybrid_search_with_score()`](https://reference.langchain.com/python/langchain-azure-cosmosdb/_vectorstore/AzureCosmosDBNoSqlVectorSearch/hybrid_search_with_score)
- [`hybrid_search_with_threshold()`](https://reference.langchain.com/python/langchain-azure-cosmosdb/_vectorstore/AzureCosmosDBNoSqlVectorSearch/hybrid_search_with_threshold)
- [`get_container()`](https://reference.langchain.com/python/langchain-azure-cosmosdb/_vectorstore/AzureCosmosDBNoSqlVectorSearch/get_container)
- [`as_retriever()`](https://reference.langchain.com/python/langchain-azure-cosmosdb/_vectorstore/AzureCosmosDBNoSqlVectorSearch/as_retriever)

---

[View source on GitHub](https://github.com/langchain-ai/langchain-azure/blob/e62c2a55aaa0942fdac739b4066011953b80018e/libs/azure-cosmosdb/src/langchain_azure_cosmosdb/_vectorstore.py#L128)