@@ -123,8 +123,17 @@ class MongoDBAtlasVectorDB(VectorDB):
if query_result and query_result[0][0]["_id"] == doc["id"]:
return
sleep(_DELAY)
raise TimeoutError(f"Document {self.index_name} is not ready!")
if (
query_result
and float(query_result[0][1]) == 1.0
and query_result[0][0].get("metadata") == doc.get("metadata")
):
# Handles edge case where document is uploaded with a specific user-generated ID, then the identical content is uploaded with a hash generated ID.
logger.warning(
f"""Documents may be ready, the search has found identical content with a different ID and {"identical" if query_result[0][0].get("metadata") == doc.get("metadata") else "different"} metadata. Duplicate ID: {str(query_result[0][0]["_id"])}"""
)
else:
raise TimeoutError(f"Document {self.index_name} is not ready!")
@@ -275,33 +284,49 @@ class MongoDBAtlasVectorDB(VectorDB):
For large numbers of Documents, insertion is performed in batches.
Documents are recommended to not have an ID field, as the method will generate Hashed ID's for them.
Args:
docs: List[Document] | A list of documents. Each document is a TypedDict `Document`.
docs: List[Document] | A list of documents. Each document is a TypedDict `Document`, which may contain an ID. Documents without ID's will have them generated.
collection_name: str | The name of the collection. Default is None.
upsert: bool | Whether to update the document if it exists. Default is False.
batch_size: Number of documents to be inserted in each batch
kwargs: Additional keyword arguments. Use `hash_length` to set the length of the hash generated ID's, use `overwrite_ids` to overwrite existing ID's with Hashed Values.