class_docstr: A component for writing documents to a DocumentStore.
docstr: Create a DocumentWriter component.
  
  :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.
docstr_tok: ["Create","a","DocumentWriter","component",".",":","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","."]
code: def __init__(
      self,
      document_store: DocumentStore,
      policy: DuplicatePolicy = DuplicatePolicy.NONE,
  ):
      """
      Create a DocumentWriter component.
  
      :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
  
file_path: haystack/haystack/components/writers/document_writer.py
imports: from typing import List, Optional, Dict, Any
  import importlib
  import logging
  from haystack import component, Document, default_from_dict, default_to_dict, DeserializationError
  from haystack.document_stores.types import DocumentStore, DuplicatePolicy
label_desc: Use image node_id 1 to create a new DocumentWriter object  with example: obj = DocumentWriter(document_store, policy)