mirror of
https://github.com/deepset-ai/haystack.git
synced 2026-01-06 03:57:19 +00:00
Change DocumentWriter default policy from DuplicatePolicy.FAIL to DuplicatePolicy.NONE (#6596)
This commit is contained in:
parent
f877704839
commit
f224f991be
@ -15,11 +15,15 @@ class DocumentWriter:
|
||||
A component for writing documents to a DocumentStore.
|
||||
"""
|
||||
|
||||
def __init__(self, document_store: DocumentStore, policy: DuplicatePolicy = DuplicatePolicy.FAIL):
|
||||
def __init__(self, document_store: DocumentStore, policy: DuplicatePolicy = DuplicatePolicy.NONE):
|
||||
"""
|
||||
Create a DocumentWriter component.
|
||||
|
||||
:param policy: The policy to use when encountering duplicate documents (default is DuplicatePolicy.FAIL).
|
||||
:param policy: the policy to apply when a Document with the same id already exists in the DocumentStore.
|
||||
- `DuplicatePolicy.NONE`: Default policy, behaviour depends on the Document Store.
|
||||
- `DuplicatePolicy.SKIP`: If a Document with the same id already exists, it is skipped and not written.
|
||||
- `DuplicatePolicy.OVERWRITE`: If a Document with the same id already exists, it is overwritten.
|
||||
- `DuplicatePolicy.FAIL`: If a Document with the same id already exists, an error is raised.
|
||||
"""
|
||||
self.document_store = document_store
|
||||
self.policy = policy
|
||||
|
||||
@ -0,0 +1,6 @@
|
||||
---
|
||||
enhancements:
|
||||
- |
|
||||
Change `DocumentWriter` default `policy` from `DuplicatePolicy.FAIL` to `DuplicatePolicy.NONE`.
|
||||
The `DocumentStore` protocol uses the same default so that different Document Stores can choose
|
||||
the default policy that better fit.
|
||||
@ -16,7 +16,7 @@ class TestDocumentWriter:
|
||||
"type": "haystack.components.writers.document_writer.DocumentWriter",
|
||||
"init_parameters": {
|
||||
"document_store": {"type": "haystack.testing.factory.MockedDocumentStore", "init_parameters": {}},
|
||||
"policy": "FAIL",
|
||||
"policy": "NONE",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user