Repository: langchain
Issue: AzureCosmosDBVectorSearch filter not working
Labels: Ɑ: vector store,🤖:bug

### Checked other resources

- [X] I added a very descriptive title to this issue.
- [X] I searched the LangChain documentation with the integrated search.
- [X] I used the GitHub search to find a similar question and didn't find it.
- [X] I am sure that this is a bug in LangChain rather than my code.
- [X] The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

### Example Code

``` python

# Filtering pipeling working in pymongo used to filter on a list of file_ids
query_embedding = self.embedding_client.embed_query(query)
pipeline = [
            {
                '$search': {
                    "cosmosSearch": {
                        "vector": query_embedding,
                        "path": "vectorContent",
                        "k": 5, #, #, "efsearch": 40 # optional for HNSW only 
                        "filter": {"fileId": {'$in': file_ids}}
                    },
                    "returnStoredSource": True }},
            {'$project': { 
                'similarityScore': { '$meta': 'searchScore' }, 
                'document' : '$$ROOT' 
                } 
            },
        ]
docs = self.mongo_collection.aggregate(pipeline)
```

# Current implementation
``` python
def _get_pipeline_vector_ivf(
        self, embeddings: List[float], k: int = 4
    ) -> List[dict[str, Any]]:
        pipeline: List[dict[str, Any]] = [
            {
                "$search": {
                    "cosmosSearch": {
                        "vector": embeddings,
                        "path": self._embedding_key,
                        "k": k,
                    },
                    "returnStoredSource": True,
                }
            },
            {
                "$project": {
                    "similarityScore": {"$meta": "searchScore"},
                    "document": "$$ROOT",
                }
            },
        ]
        return pipeline

def _get_pipeline_vector_hnsw(
        self, embeddings: List[float], k: int = 4, ef_search: int = 40
    ) -> List[dict[str, Any]]:
        pipeline: List[dict[str, Any]] = [
            {
                "$search": {
                    "cosmosSearch": {
                        "vector": embeddings,
                        "path": self._embedding_key,
                        "k": k,
                        "efSearch": ef_search,
                    },
                }
            },
            {
                "$project": {
                    "similarityScore": {"$meta": "searchScore"},
                    "document": "$$ROOT",
                }
            },
        ]
        return pipeline
```
### Error Message and Stack Trace (if applicable)

_No response_

### Description

As stated in the langchain documentation filtering in Azure Cosmos DB Mongo vCore should be supported: https://python.langchain.com/v0.2/docs/integrations/vectorstores/azure_cosmos_db/

Filtering works when I apply my MongoDB query directly using pyomongo as shown in the example. However, through langchain the same filters are not applied. I tried using the filter, pre_filter, search_kwargs and kwargs parameters, but to no avail.

``` python
docs = self.vectorstore.similarity_search(query, 
    k=5, 
    pre_filter = {'fileId': {'$in': ["31c283c2-ac31-4260-a8d0-864f444c33ee]"}}
)
```
Upon closer inspection of the source code, I see that no filter key is present in the query dictionary and see no kwargs, search_kwargs being passed, which could be the reason. 
https://github.com/langchain-ai/langchain/blob/master/libs/community/langchain_community/vectorstores/azure_cosmos_db.py

Any input on this issue?

### System Info

System Information
------------------
> OS:  Windows
> OS Version:  10.0.22631
> Python Version:  3.11.4 (tags/v3.11.4:d2340ef, Jun  7 2023, 05:45:37) [MSC v.1934 64 bit (AMD64)]

Package Information
-------------------
> langchain_core: 0.2.10
> langchain: 0.2.6
> langchain_community: 0.2.6
> langsmith: 0.1.82
> langchain_openai: 0.1.13
> langchain_text_splitters: 0.2.2

Packages not installed (Not Necessarily a Problem)
--------------------------------------------------
The following packages were not found:

> langgraph
> langserve