langchain/docs/docs/integrations
AthulVincent 67c55cb5b0
Implemented MongoDB Atlas Self-Query Retriever (#13321)
# Description 
This PR implements Self-Query Retriever for MongoDB Atlas vector store.

I've implemented the comparators and operators that are supported by
MongoDB Atlas vector store according to the section titled "Atlas Vector
Search Pre-Filter" from
https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage/.

Namely:
```
allowed_comparators = [
      Comparator.EQ,
      Comparator.NE,
      Comparator.GT,
      Comparator.GTE,
      Comparator.LT,
      Comparator.LTE,
      Comparator.IN,
      Comparator.NIN,
  ]

"""Subset of allowed logical operators."""
allowed_operators = [
    Operator.AND,
    Operator.OR
]
```
Translations from comparators/operators to MongoDB Atlas filter
operators(you can find the syntax in the "Atlas Vector Search
Pre-Filter" section from the previous link) are done using the following
dictionary:
```
map_dict = {
            Operator.AND: "$and",
            Operator.OR: "$or",
            Comparator.EQ: "$eq",
            Comparator.NE: "$ne",
            Comparator.GTE: "$gte",
            Comparator.LTE: "$lte",
            Comparator.LT: "$lt",
            Comparator.GT: "$gt",
            Comparator.IN: "$in",
            Comparator.NIN: "$nin",
        }
```

In visit_structured_query() the filters are passed as "pre_filter" and
not "filter" as in the MongoDB link above since langchain's
implementation of MongoDB atlas vector
store(libs\langchain\langchain\vectorstores\mongodb_atlas.py) in
_similarity_search_with_score() sets the "filter" key to have the value
of the "pre_filter" argument.
```
params["filter"] = pre_filter
```
Test cases and documentation have also been added.

# Issue
#11616 

# Dependencies
No new dependencies have been added.

# Documentation
I have created the notebook mongodb_atlas_self_query.ipynb outlining the
steps to get the self-query mechanism working.

I worked closely with [@Farhan-Faisal](https://github.com/Farhan-Faisal)
on this PR.

---------

Co-authored-by: Bagatur <baskaryan@gmail.com>
2023-11-29 22:05:06 -05:00
..
adapters DOCS: move adapters to integrations (#13862) 2023-11-27 13:05:43 -08:00
callbacks DOCS: format notebooks (#13371) 2023-11-14 14:17:44 -08:00
chat langchain[minor]: add volcengine endpoint as LLM (#13942) 2023-11-29 13:16:42 -08:00
chat_loaders DOCS: format notebooks (#13371) 2023-11-14 14:17:44 -08:00
document_loaders DROP BOX Loader Documentation Update (#14047) 2023-11-29 17:25:35 -08:00
document_transformers DOCS: format notebooks (#13371) 2023-11-14 14:17:44 -08:00
llms langchain[minor]: add volcengine endpoint as LLM (#13942) 2023-11-29 13:16:42 -08:00
memory Astra DB, chat message history (#13836) 2023-11-24 18:12:29 -08:00
platforms docs microsoft page updates (#14000) 2023-11-28 22:20:21 -05:00
providers langchain[minor]: Add StackExchange API integration (#14002) 2023-11-29 10:32:07 -08:00
retrievers Implemented MongoDB Atlas Self-Query Retriever (#13321) 2023-11-29 22:05:06 -05:00
text_embedding langchain[minor]: Adding infinity embedding integration. (#13928) 2023-11-27 16:43:47 -08:00
toolkits FEAT: Add azure cognitive health tool (#13448) 2023-11-19 18:44:01 -08:00
tools Add multi-input Reddit search tool (#13893) 2023-11-29 20:16:40 -05:00
vectorstores docs[patch]: fix typo langchain version for mongodb integration (#14006) 2023-11-28 21:20:30 -08:00