Find answers from the community

Updated last year

Hi all I m attempting to use the

Hi all, I'm attempting to use the MongoDBAtlasVectorStore, but am running into some problems. Whenever I want to query an index that is using this VectorStore, I get the following pymongo error

Plain Text
pymongo.errors.OperationFailure: Error connecting to localhost:28000 (127.0.0.1:28000) :: caused by :: Connection refused, full error: {'ok': 0.0, 'errmsg': 'Error connecting to localhost:28000 (127.0.0.1:28000) :: caused by :: Connection refused', 'code': 6, 'codeName': 'HostUnreachable', <timestamps and metadata>}


Apparently this is because my collection in MongoDbAtlas cloud does not have a search index created. I created a search index on the default_collection, which I think is the right collection to index (as this one contains the properties: ID, embedding and text)

After creating a basic search engine I now get the following error from pymongo when querying

Plain Text
pymongo.errors.OperationFailure: embedding is not indexed as kNN, full error: {'ok': 0.0, 'errmsg': 'embedding is not indexed as kNN', 'code': 8, 'codeName': 'UnknownError' <timestamps and metadata>}


Did I miss a setup or a wiki page regarding the configuration of MongoDBAtlas, or am I supposed to manually create a search index and map it to the appropriate fields? Thanks in advance!
O
L
9 comments
To resolve this issue fully

  1. Create Search Index in MongoDB Atlas GUI / API / whatever
  2. Specify to use the `default_db/default_collection that is stored in your MongoDBAtlas from using the VectorStore
  3. Edit the search object in JSON and at least specify the text field as follows
(info can be found here https://www.mongodb.com/docs/atlas/atlas-search/field-types/knn-vector/#define-the-index-for-the-fts-field-type-type)
Plain Text
{
  "mappings": {
    "dynamic": true,
    "fields": {
      "text": {
        "dimensions": 1536, // when using text-ada-002
        "similarity": "dotProduct", // Different one might be better, idk
        "type": "knnVector"
      }
    }
  }
}

  1. Query again and hopefully retrieve your relevant sources from the store
However, this seems over the top for working with the MongoDBAtlasVectorSearch. It is also not listed anywhere in the documentation that these steps have to be followed. Is the documentation outdated, or did I not look in the right places?
Yup, you got it. Its EXTREMELY janky
tbh I wouldn't recommend anyone uses this because of how complicated it is πŸ˜† But glad you got it working!
That's some overhead if I've ever seen one. However, I did read that this can be configured through the API / SDK. Potentially interesting issue to research how to set up the AtlasVectorSearch dynamically
(if it's not an issue already)
I'm not sure if their python api provides a way to do it on the fly 😦
at least the last time I looked
Ahhh that's tragic
Add a reply
Sign up and join the conversation on Discord