Привет всем!
Мне нужно помогите со следующей функцией:
Код: Выделить всё
def add_collection_content_vector_field(collection_name: str):
'''
Add a new field to the collection to hold the vectorized content of each document.
'''
collection = db[collection_name]
bulk_operations = []
for doc in collection.find():
if "contentVector" in doc:
del doc["contentVector"]
content = json.dumps(doc, default=str)
content_vector = generate_embeddings(content)
bulk_operations.append(pymongo.UpdateOne(
{"_id": doc["_id"]},
{"$set": {"contentVector": content_vector}},
upsert=True
))
collection.bulk_write(bulk_operations)
Код: Выделить всё
CursorNotFound: cursor id not found, full error: {'ok': 0.0, 'errmsg': 'cursor id not found', 'code': 43, 'codeName': 'CursorNotFound', '$clusterTime': {'clusterTime': Timestamp(1715923790, 2), 'signature': {'hash': b'\xca\x8f9\xf0f!'\xdb\xf5r\xbb\xe0\xf4to\xcc1\x93\x8e', 'keyId': 7313113004709511172}}, 'operationTime': Timestamp(1715923790, 2)}
Спасибо!
Я попробовал запустить функцию add_collection_content_vector_field( "sales"), чтобы добавить новое поле в каждый документ в коллекции "sales". Я ожидал, что функция будет перебирать все документы, генерировать внедрения и обновлять каждый документ новым полем contentVector.
Однако после обработки некоторых документов я столкнулся со следующей ошибкой. :
Код: Выделить всё
CursorNotFound: cursor id not found, full error: {'ok': 0.0, 'errmsg': 'cursor id not found', 'code': 43, 'codeName': 'CursorNotFound', '$clusterTime': {'clusterTime': Timestamp(1715923790, 2), 'signature': {'hash': b'\xca\x8f9\xf0f!'\xdb\xf5r\xbb\xe0\xf4to\xcc1\x93\x8e', 'keyId': 7313113004709511172}}, 'operationTime': Timestamp(1715923790, 2)}
Подробнее здесь: https://stackoverflow.com/questions/784 ... ornotfound