mirror of
https://github.com/deepset-ai/haystack.git
synced 2026-01-08 04:56:45 +00:00
feat: extend write_documents to return the number of documents actually written in the document store (#6006)
* add typing and docstring * reno * Update releasenotes/notes/extend-write-documents-855ffc315974f03b.yaml Co-authored-by: Silvano Cerza <3314350+silvanocerza@users.noreply.github.com> --------- Co-authored-by: Silvano Cerza <3314350+silvanocerza@users.noreply.github.com>
This commit is contained in:
parent
4ef2a680bb
commit
9cee2f82c4
@ -113,7 +113,7 @@ class DocumentStore(Protocol):
|
||||
:return: a list of Documents that match the given filters.
|
||||
"""
|
||||
|
||||
def write_documents(self, documents: List[Document], policy: DuplicatePolicy = DuplicatePolicy.FAIL) -> None:
|
||||
def write_documents(self, documents: List[Document], policy: DuplicatePolicy = DuplicatePolicy.FAIL) -> int:
|
||||
"""
|
||||
Writes (or overwrites) documents into the DocumentStore.
|
||||
|
||||
@ -124,7 +124,9 @@ class DocumentStore(Protocol):
|
||||
- overwrite: remove the old document and write the new one.
|
||||
- fail: an error is raised
|
||||
:raises DuplicateError: Exception trigger on duplicate document if `policy=DuplicatePolicy.FAIL`
|
||||
:return: None
|
||||
:return: The number of documents that was written.
|
||||
If DuplicatePolicy.OVERWRITE is used, this number is always equal to the number of documents in input.
|
||||
If DuplicatePolicy.SKIP is used, this number can be lower than the number of documents in the input list.
|
||||
"""
|
||||
|
||||
def delete_documents(self, document_ids: List[str]) -> None:
|
||||
|
||||
@ -0,0 +1,2 @@
|
||||
preview:
|
||||
- Change `write_documents()` method in `DocumentStore` protocol to return the number of document written
|
||||
Loading…
x
Reference in New Issue
Block a user