Custom Metadata Filtering Now Available
Cloudflare has expanded AI Search with custom metadata filtering capabilities, enabling developers to define custom metadata schemas and filter search results based on application-specific attributes.
Defining Custom Metadata
You can define up to 5 custom metadata fields per AI Search instance. Each field requires a name and data type (text, number, or boolean). Custom metadata schemas are configured when creating or updating an AI Search instance via the Cloudflare API.
Setting Metadata on Documents
How you attach metadata to your documents depends on your data source:
- R2 Buckets: Use S3-compatible custom headers (
x-amz-meta-*) when uploading objects to attach metadata to files - Websites: Add standard HTML
<meta>tags to your pages to define metadata fields
Filtering Search Results
Custom metadata fields can be used as filters in search queries alongside built-in attributes like folder and timestamp. Use the ai_search_options.retrieval.filters parameter to specify filter conditions, including support for comparison operators like $gte for range-based filtering.
Getting Started
Refer to the metadata filtering documentation for detailed configuration examples and best practices for your specific data source.