Repository: langchain
Issue: MongoDBAtlasVectorSearch missing create_vector_search_index method as documented
Labels: Ɑ: vector store,stale

### 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



### To Reproduce
Here’s the code I am using, based on the documentation:


from langchain_mongodb import MongoDBAtlasVectorSearch
from pymongo import MongoClient
import os

class AtlasDb:

    def __init__(self):
        mongodb_uri = os.getenv("MONGODB_ATLAS_CLUSTER_URI")
        db_name = os.getenv("VECTOR_DB_NAME")
        collection_name = os.getenv("VECTOR_DB_COLLECTION_NAME")
        index_name = os.getenv("VECTOR_DB_INDEX_NAME")

        # Initialize MongoDB client
        self.client = MongoClient(mongodb_uri)
        self.db = self.client[db_name]
        self.collection = self.db[collection_name]
        
        # Initialize embeddings model
        self.embeddings = OpenAIEmbeddings(model="text-embedding-ada-002")

        # Initialize the vector store
        self.vector_store = MongoDBAtlasVectorSearch(
            collection=self.collection,
            embedding=self.embeddings,
            index_name=index_name,
            text_key="page_content",
            relevance_score_fn="cosine",
        )
        
        # Attempt to create vector search index
        self.vector_store.create_vector_search_index(dimensions=1536)  # Error occurs here




### Error Message and Stack Trace (if applicable)

AttributeError: 'MongoDBAtlasVectorSearch' object has no attribute 'create_vector_search_index'


### Description

I'm following the LangChain documentation (https://python.langchain.com/docs/integrations/vectorstores/mongodb_atlas/) for creating a vector store index with MongoDB Atlas using the MongoDBAtlasVectorSearch class. However, when I attempt to call create_vector_search_index, I get an error indicating that this method does not exist.


Documentation Reference
The LangChain documentation suggests using create_vector_search_index on the MongoDBAtlasVectorSearch object with the following code:
vector_store.create_vector_search_index(dimensions=1536)



As a workaround, I found that I could create the index manually through the MongoDB Atlas UI with the following index definition:

json
Copy code
{
  "fields":[
    {
      "type": "vector",
      "path": "embedding",
      "numDimensions": 1536,
      "similarity": "cosine"
    }
  ]
}
This manual setup works, but the absence of the create_vector_search_index method in the codebase could be misleading for other users following the documentation.


### System Info

(abogacia) C:\Users\ASUS\Desktop\projects\Abogacy-AI>pip freeze
aiohttp==3.9.5
aiosignal==1.3.1
annotated-types==0.7.0
anyio==4.4.0
asgiref==3.8.1
asttokens==2.4.1
attrs==23.2.0
backcall==0.2.0
backoff==2.2.1
bcrypt==4.1.3
beautifulsoup4==4.12.3
bleach==6.1.0
build==1.2.1
cachetools==5.3.3
certifi==2024.6.2
cffi==1.16.0
charset-normalizer==3.3.2
chroma-hnswlib==0.7.3
chromadb==0.5.3
click==8.1.7
colorama==0.4.6
coloredlogs==15.0.1
cryptography==43.0.0
dataclasses-json==0.6.7
decorator==5.1.1
defusedxml==0.7.1
Deprecated==1.2.14
distro==1.9.0
dnspython==2.6.1
docopt==0.6.2
docx2txt==0.8
email_validator==2.2.0
executing==2.0.1
fastapi==0.111.0
fastapi-cli==0.0.4
fastjsonschema==2.20.0
filelock==3.15.4
flatbuffers==24.3.25
frozenlist==1.4.1
fsspec==2024.6.1
gitdb==4.0.11
GitPython==3.1.43
google-auth==2.31.0
googleapis-common-protos==1.63.2
greenlet==3.0.3
grpcio==1.64.1
h11==0.14.0
httpcore==1.0.5
httptools==0.6.1
httpx==0.27.0
huggingface-hub==0.23.4
humanfriendly==10.0
idna==3.7
importlib_metadata==7.1.0
importlib_resources==6.4.0
ipython==8.12.3
jedi==0.19.1
Jinja2==3.1.4
jsonpatch==1.33
jsonpointer==3.0.0
jsonschema==4.23.0
jsonschema-specifications==2023.12.1
jupyter_client==8.6.2
jupyter_core==5.7.2
jupyterlab_pygments==0.3.0
kubernetes==30.1.0
langchain==0.2.15
langchain-community==0.2.15
langchain-core==0.2.37
langchain-experimental==0.0.64
langchain-mongodb==0.1.6
langchain-openai==0.1.14
langchain-text-splitters==0.2.2
langsmith==0.1.84
markdown-it-py==3.0.0
MarkupSafe==2.1.5
marshmallow==3.21.3
matplotlib-inline==0.1.7
mdurl==0.1.2
mistune==3.0.2
mmh3==4.1.0
monotonic==1.6
mpmath==1.3.0
multidict==6.0.5
mypy-extensions==1.0.0
nbclient==0.10.0
nbconvert==7.16.4
nbformat==5.10.4
neo4j==5.24.0
numpy==1.26.4
oauthlib==3.2.2
onnxruntime==1.18.1
openai==1.35.10
opentelemetry-api==1.25.0
opentelemetry-exporter-otlp-proto-common==1.25.0
opentelemetry-exporter-otlp-proto-grpc==1.25.0
opentelemetry-instrumentation==0.46b0
opentelemetry-instrumentation-asgi==0.46b0
opentelemetry-instrumentation-fastapi==0.46b0
opentelemetry-proto==1.25.0
opentelemetry-sdk==1.25.0
opentelemetry-semantic-conventions==0.46b0
opentelemetry-util-http==0.46b0
orjson==3.10.6
outcome==1.3.0.post0
overrides==7.7.0
packaging==24.1
pandocfilters==1.5.1
parso==0.8.4
pdfminer.six==20240706
pickleshare==0.7.5
pipreqs==0.5.0
platformdirs==4.2.2
posthog==3.5.0
prompt_toolkit==3.0.47
protobuf==4.25.3
pure_eval==0.2.3
pyasn1==0.6.0
pyasn1_modules==0.4.0
pycparser==2.22
pydantic==2.8.2
pydantic_core==2.20.1
Pygments==2.18.0
pymongo==4.8.0
PyMuPDF==1.24.7
PyMuPDFb==1.24.6
pypdf==4.2.0
PyPika==0.48.9
pyproject_hooks==1.1.0
pyreadline3==3.4.1
PySocks==1.7.1
python-dateutil==2.9.0.post0
python-dotenv==1.0.1
python-multipart==0.0.9
pytz==2024.1
pywin32==306
PyYAML==6.0.1
pyzmq==26.1.0
referencing==0.35.1
regex==2024.5.15
requests==2.32.3
requests-oauthlib==2.0.0
rich==13.7.1
rpds-py==0.20.0
rsa==4.9
selenium==4.21.0
setuptools==69.5.1
shellingham==1.5.4
six==1.16.0
smmap==5.0.1
sniffio==1.3.1
sortedcontainers==2.4.0
soupsieve==2.5
SQLAlchemy==2.0.31
stack-data==0.6.3
starlette==0.37.2
sympy==1.12.1
tenacity==8.5.0
tiktoken==0.7.0
tinycss2==1.3.0
tokenizers==0.19.1
tornado==6.4.1
tqdm==4.66.4
traitlets==5.14.3
trio==0.25.1
trio-websocket==0.11.1
typer==0.12.3
typing-inspect==0.9.0
typing_extensions==4.12.2
ujson==5.10.0
urllib3==2.2.1
uvicorn==0.30.1
watchfiles==0.22.0
wcwidth==0.2.13
webdriver-manager==4.0.1
webencodings==0.5.1
websocket-client==1.8.0
websockets==12.0
wheel==0.43.0
wrapt==1.16.0
wsproto==1.2.0
yarg==0.1.9
yarl==1.9.4
zipp==3.19.2