test_add_documents_by_id_with_mutation() — langchain Function Reference
Architecture documentation for the test_add_documents_by_id_with_mutation() function in vectorstores.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 9fc9a63d_6ebb_cef1_b281_1f9440391d8a["test_add_documents_by_id_with_mutation()"] dd52cc1a_cb37_0117_3b1e_0889a7228307["VectorStoreIntegrationTests"] 9fc9a63d_6ebb_cef1_b281_1f9440391d8a -->|defined in| dd52cc1a_cb37_0117_3b1e_0889a7228307 style 9fc9a63d_6ebb_cef1_b281_1f9440391d8a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/standard-tests/langchain_tests/integration_tests/vectorstores.py lines 289–326
def test_add_documents_by_id_with_mutation(self, vectorstore: VectorStore) -> None:
"""Test that we can overwrite by ID using `add_documents`.
??? note "Troubleshooting"
If this test fails, check that when `add_documents` is called with an
ID that already exists in the vector store, the content is updated
rather than duplicated.
"""
if not self.has_sync:
pytest.skip("Sync tests not supported.")
documents = [
Document(page_content="foo", metadata={"id": 1}),
Document(page_content="bar", metadata={"id": 2}),
]
vectorstore.add_documents(documents=documents, ids=["1", "2"])
# Now over-write content of ID 1
new_documents = [
Document(
page_content="new foo", metadata={"id": 1, "some_other_field": "foo"}
),
]
vectorstore.add_documents(documents=new_documents, ids=["1"])
# Check that the content has been updated
documents = vectorstore.similarity_search("new foo", k=2)
assert documents == [
Document(
id="1",
page_content="new foo",
metadata={"id": 1, "some_other_field": "foo"},
),
Document(id="2", page_content="bar", metadata={"id": 2}),
]
Domain
Subdomains
Source
Frequently Asked Questions
What does test_add_documents_by_id_with_mutation() do?
test_add_documents_by_id_with_mutation() is a function in the langchain codebase, defined in libs/standard-tests/langchain_tests/integration_tests/vectorstores.py.
Where is test_add_documents_by_id_with_mutation() defined?
test_add_documents_by_id_with_mutation() is defined in libs/standard-tests/langchain_tests/integration_tests/vectorstores.py at line 289.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free