Skip to content

Class swarmauri_core.document_stores.IDocumentStore.IDocumentStore

swarmauri_core.document_stores.IDocumentStore.IDocumentStore

Bases: ABC

Interface for a Document Store responsible for storing, indexing, and retrieving documents.

add_document abstractmethod

add_document(document)

Stores a single document in the document store.

Parameters: - document (IDocument): The document to store.

Source code in swarmauri_core/document_stores/IDocumentStore.py
11
12
13
14
15
16
17
18
19
@abstractmethod
def add_document(self, document: IDocument) -> None:
    """
    Stores a single document in the document store.

    Parameters:
    - document (IDocument): The document to store.
    """
    pass

add_documents abstractmethod

add_documents(documents)

Stores multiple documents in the document store.

Parameters: - documents (List[IDocument]): The list of documents to store.

Source code in swarmauri_core/document_stores/IDocumentStore.py
21
22
23
24
25
26
27
28
29
@abstractmethod
def add_documents(self, documents: List[IDocument]) -> None:
    """
    Stores multiple documents in the document store.

    Parameters:
    - documents (List[IDocument]): The list of documents to store.
    """
    pass

get_document abstractmethod

get_document(doc_id)

Retrieves a document by its ID.

Parameters: - doc_id (str): The unique identifier for the document.

Returns: - Union[IDocument, None]: The requested document, or None if not found.

Source code in swarmauri_core/document_stores/IDocumentStore.py
31
32
33
34
35
36
37
38
39
40
41
42
@abstractmethod
def get_document(self, doc_id: str) -> Union[IDocument, None]:
    """
    Retrieves a document by its ID.

    Parameters:
    - doc_id (str): The unique identifier for the document.

    Returns:
    - Union[IDocument, None]: The requested document, or None if not found.
    """
    pass

get_all_documents abstractmethod

get_all_documents()

Retrieves all documents stored in the document store.

Returns: - List[IDocument]: A list of all documents.

Source code in swarmauri_core/document_stores/IDocumentStore.py
44
45
46
47
48
49
50
51
52
@abstractmethod
def get_all_documents(self) -> List[IDocument]:
    """
    Retrieves all documents stored in the document store.

    Returns:
    - List[IDocument]: A list of all documents.
    """
    pass

delete_document abstractmethod

delete_document(doc_id)

Deletes a document from the document store by its ID.

Parameters: - doc_id (str): The unique identifier of the document to delete.

Source code in swarmauri_core/document_stores/IDocumentStore.py
54
55
56
57
58
59
60
61
62
@abstractmethod
def delete_document(self, doc_id: str) -> None:
    """
    Deletes a document from the document store by its ID.

    Parameters:
    - doc_id (str): The unique identifier of the document to delete.
    """
    pass

update_document abstractmethod

update_document(doc_id, updated_document)

Updates a document in the document store.

Parameters: - doc_id (str): The unique identifier for the document to update. - updated_document (IDocument): The updated document object.

Note: It's assumed that the updated_document will retain the same doc_id but may have different content or metadata.

Source code in swarmauri_core/document_stores/IDocumentStore.py
64
65
66
67
68
69
70
71
72
73
74
75
@abstractmethod
def update_document(self, doc_id: str, updated_document: IDocument) -> None:
    """
    Updates a document in the document store.

    Parameters:
    - doc_id (str): The unique identifier for the document to update.
    - updated_document (IDocument): The updated document object.

    Note: It's assumed that the updated_document will retain the same doc_id but may have different content or metadata.
    """
    pass

document_count abstractmethod

document_count()
Source code in swarmauri_core/document_stores/IDocumentStore.py
77
78
79
@abstractmethod
def document_count(self) -> int:
    pass