Skip to content

Base

BaseDocumentStore

Bases: ABC

A document store is in charged of storing and managing documents

Source code in libs\kotaemon\kotaemon\storages\docstores\base.py
class BaseDocumentStore(ABC):
    """A document store is in charged of storing and managing documents"""

    @abstractmethod
    def __init__(self, *args, **kwargs):
        ...

    @abstractmethod
    def add(
        self,
        docs: Union[Document, List[Document]],
        ids: Optional[Union[List[str], str]] = None,
        **kwargs,
    ):
        """Add document into document store

        Args:
            docs: Document or list of documents
            ids: List of ids of the documents. Optional, if not set will use doc.doc_id
        """
        ...

    @abstractmethod
    def get(self, ids: Union[List[str], str]) -> List[Document]:
        """Get document by id"""
        ...

    @abstractmethod
    def get_all(self) -> List[Document]:
        """Get all documents"""
        ...

    @abstractmethod
    def count(self) -> int:
        """Count number of documents"""
        ...

    @abstractmethod
    def delete(self, ids: Union[List[str], str]):
        """Delete document by id"""
        ...

    @abstractmethod
    def drop(self):
        """Drop the document store"""
        ...

add abstractmethod

add(docs, ids=None, **kwargs)

Add document into document store

Parameters:

Name Type Description Default
docs Union[Document, List[Document]]

Document or list of documents

required
ids Optional[Union[List[str], str]]

List of ids of the documents. Optional, if not set will use doc.doc_id

None
Source code in libs\kotaemon\kotaemon\storages\docstores\base.py
@abstractmethod
def add(
    self,
    docs: Union[Document, List[Document]],
    ids: Optional[Union[List[str], str]] = None,
    **kwargs,
):
    """Add document into document store

    Args:
        docs: Document or list of documents
        ids: List of ids of the documents. Optional, if not set will use doc.doc_id
    """
    ...

get abstractmethod

get(ids)

Get document by id

Source code in libs\kotaemon\kotaemon\storages\docstores\base.py
@abstractmethod
def get(self, ids: Union[List[str], str]) -> List[Document]:
    """Get document by id"""
    ...

get_all abstractmethod

get_all()

Get all documents

Source code in libs\kotaemon\kotaemon\storages\docstores\base.py
@abstractmethod
def get_all(self) -> List[Document]:
    """Get all documents"""
    ...

count abstractmethod

count()

Count number of documents

Source code in libs\kotaemon\kotaemon\storages\docstores\base.py
@abstractmethod
def count(self) -> int:
    """Count number of documents"""
    ...

delete abstractmethod

delete(ids)

Delete document by id

Source code in libs\kotaemon\kotaemon\storages\docstores\base.py
@abstractmethod
def delete(self, ids: Union[List[str], str]):
    """Delete document by id"""
    ...

drop abstractmethod

drop()

Drop the document store

Source code in libs\kotaemon\kotaemon\storages\docstores\base.py
@abstractmethod
def drop(self):
    """Drop the document store"""
    ...