fastrag.ingestion.filters.contentformat#

ContentFormatFilter: filters documents by their content format.

Classes

ContentFormatFilter([include_formats, ...])

Filters documents by metadata["content_format"].

class fastrag.ingestion.filters.contentformat.ContentFormatFilter(include_formats=None, exclude_formats=None)[source]#

Bases: Filter[Document]

Filters documents by metadata["content_format"].

Unlike MediaTypeFilter, a document carrying no recorded format is not treated as unmatchable — it is treated as TEXT, since every document that existed before content_format was introduced is plain text by definition.

Parameters:
property header_safe: bool#

This predicate uses identity/metadata only.

matches(item)[source]#

Return True when item’s content format passes the filter.

Reads item.metadata["content_format"], defaulting to TEXT when the key is absent.

Parameters:

item (Document)

Return type:

bool