update_document_by_filename_with_text

Update a document identified by filename with new text content using the specified strategy.

def update_document_by_filename_with_text(
    filename: str,
    content: str,
    new_filename: Optional[str] = None,
    metadata: Optional[Dict[str, Any]] = None,
    rules: Optional[List] = None,
    update_strategy: str = "add",
    use_colpali: Optional[bool] = None,
) -> Document

Parameters

  • filename (str): Filename of the document to update
  • content (str): The new content to add
  • new_filename (str, optional): Optional new filename for the document
  • metadata (Dict[str, Any], optional): Additional metadata to update
  • rules (List, optional): Optional list of rules to apply to the content
  • update_strategy (str, optional): Strategy for updating the document (currently only ‘add’ is supported). Defaults to ‘add’.
  • use_colpali (bool, optional): Whether to use multi-vector embedding. If not specified, defaults to True.

Returns

  • Document: Updated document metadata

Example

from databridge.sync import DataBridge

db = DataBridge()

# Add new content to an existing document identified by filename
updated_doc = db.update_document_by_filename_with_text(
    filename="report.pdf",
    content="This is additional content that will be appended to the document.",
    new_filename="updated_report.pdf",
    metadata={"category": "updated"},
    update_strategy="add"
)
print(f"Document version: {updated_doc.system_metadata.get('version')}")