Hello.
I am getting a similar problem using python. My embeddings are all saved under a field called wod_embedding_openai:
And I have a search index called wod_vector_index_openai that targets this same field/path:
And here is my Python code:
from langchain_community.vectorstores import MongoDBAtlasVectorSearch
from pymongo.mongo_client import MongoClient
from langchain_openai import OpenAIEmbeddings
import certifi
DB_NAME = "xfitpal"
COLLECTION_NAME = "wods"
mongoUri = os.environ.get("MONGO_ATLAS_DB_URL")
mongoClient = MongoClient(mongoUri, tlsCAFile=certifi.where())
mongoDb = mongoClient[DB_NAME]
wods_collection = mongoDb[COLLECTION_NAME]
vectorStore = MongoDBAtlasVectorSearch(
wods_collection, OpenAIEmbeddings(openai_api_key=OPENAI_API_KEY), index_name='wod_vector_index_openai'
)
docs = vectorStore.similarity_search('MY_QUERY_GOES_HERE', K=1)
print(docs)
When I run it, I get the error mentioned in one of the comments above:
raise OperationFailure(errmsg, code, response, max_wire_version)
pymongo.errors.OperationFailure: PlanExecutor error during aggregation :: caused by :: embedding is not indexed as knnVector, full error: {'ok': 0.0, 'errmsg': 'PlanExecutor error during aggregation :: caused by :: embedding is not indexed as knnVector', 'code': 8, 'codeName': 'UnknownError', '$clusterTime': {'clusterTime': Timestamp(1706467324, 22), 'operationTime': Timestamp(1706467324, 22)}
Btw, this is giving me a timeout error in a virtual environment set up with Python 3.12. So I have to run it under python 3.11 and that is when I get the above error.
Any ideas? Appreciate any help.
