Home / Function/ test_get_by_ids() — langchain Function Reference

test_get_by_ids() — langchain Function Reference

Architecture documentation for the test_get_by_ids() function in vectorstores.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  bb0fffd8_7951_8349_e293_eee2926357f0["test_get_by_ids()"]
  dd52cc1a_cb37_0117_3b1e_0889a7228307["VectorStoreIntegrationTests"]
  bb0fffd8_7951_8349_e293_eee2926357f0 -->|defined in| dd52cc1a_cb37_0117_3b1e_0889a7228307
  26edf390_ce50_b6e2_04c9_788f2cd6faba["has_get_by_ids()"]
  bb0fffd8_7951_8349_e293_eee2926357f0 -->|calls| 26edf390_ce50_b6e2_04c9_788f2cd6faba
  ec7f22d1_3913_61c4_fadb_bb7d144c0fb3["_sort_by_id()"]
  bb0fffd8_7951_8349_e293_eee2926357f0 -->|calls| ec7f22d1_3913_61c4_fadb_bb7d144c0fb3
  style bb0fffd8_7951_8349_e293_eee2926357f0 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/standard-tests/langchain_tests/integration_tests/vectorstores.py lines 328–367

    def test_get_by_ids(self, vectorstore: VectorStore) -> None:
        """Test get by IDs.

        This test requires that `get_by_ids` be implemented on the vector store.

        ??? note "Troubleshooting"

            If this test fails, check that `get_by_ids` is implemented and returns
            documents in the same order as the IDs passed in.

            !!! note
                `get_by_ids` was added to the `VectorStore` interface in
                `langchain-core` version 0.2.11. If difficult to implement, this
                test can be skipped by setting the `has_get_by_ids` property to
                `False`.

                ```python
                @property
                def has_get_by_ids(self) -> bool:
                    return False
                ```
        """
        if not self.has_sync:
            pytest.skip("Sync tests not supported.")

        if not self.has_get_by_ids:
            pytest.skip("get_by_ids not implemented.")

        documents = [
            Document(page_content="foo", metadata={"id": 1}),
            Document(page_content="bar", metadata={"id": 2}),
        ]
        ids = vectorstore.add_documents(documents, ids=["1", "2"])
        retrieved_documents = vectorstore.get_by_ids(ids)
        assert _sort_by_id(retrieved_documents) == _sort_by_id(
            [
                Document(page_content="foo", metadata={"id": 1}, id=ids[0]),
                Document(page_content="bar", metadata={"id": 2}, id=ids[1]),
            ]
        )

Domain

Subdomains

Frequently Asked Questions

What does test_get_by_ids() do?
test_get_by_ids() is a function in the langchain codebase, defined in libs/standard-tests/langchain_tests/integration_tests/vectorstores.py.
Where is test_get_by_ids() defined?
test_get_by_ids() is defined in libs/standard-tests/langchain_tests/integration_tests/vectorstores.py at line 328.
What does test_get_by_ids() call?
test_get_by_ids() calls 2 function(s): _sort_by_id, has_get_by_ids.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free