Dynamic Filter Rules in Internal Search
5 min read
BETA
This feature is currently BETA and requires enabling the feature flag FEATURE_FLAG_ENABLE_DYNAMIC_SCOPE_RULE_UN_17614.
Overview
Dynamic Filter Rules extend the Internal Search tooling by allowing the LLM to extract structured parameters directly from the user query at tool-call time and apply those parameters as metadata filters during document retrieval.
This enables more intelligent and context-aware retrieval flows without hardcoding filter values into the scope configuration.
Typical use cases include:
Filtering documents by location
Filtering documents by department
Filtering documents by region
Filtering documents by valid dates or effective dates
Filtering documents by customer, project, or product line
Unlike static scope rules, dynamic filters are evaluated dynamically for every user request.

Concept
The Knowledge Scope Rules UI now supports two types of filtering:
Static Filters
Static filters are always applied exactly as configured.
Examples:
Only include documents from a specific folder
Only include documents with a specific metadata value
Restrict retrieval to a fixed knowledge base segment
These rules:
do not contain placeholders
are compiled before the agent starts
behave exactly like the existing scope rules functionality

Static filter - All files within a folder are considered for the search
Dynamic Filters
Dynamic filters allow administrators to define:
Parameters that should be extracted from the user query
Rules that use these extracted parameters to filter documents dynamically
The LLM extracts values from the user input. Those extracted values are then injected into UniqueQL scope rules and compiled into metadata filters during search execution.
This makes retrieval adaptive to the user request while still remaining fully controlled by the configured scope rules.
How Dynamic Filtering Works
Step 1 — Define Tool Parameters
Administrators define parameters that should be extracted from the user query.
Each parameter contains:
Field | Description |
|---|---|
Name | Parameter identifier |
Type | Data type (string, date, etc.) |
Description | Instructions for the LLM on what to extract |
Required | Defines whether extraction is mandatory |
A mandatory parameter is always processed by the LLM for every user query. If the parameter is not required or cannot be inferred from the query context, the extracted value is None and the parameter is ignored during search construction. If the parameter is required, the LLM must attempt extraction. When extraction fails (for example, no location information is available), the parameter is returned as an empty string ("") rather than None.
Example:
Query | Location required? | Extracted value |
|---|---|---|
“Best restaurants in Zurich” | Yes | "Zurich" |
“Best restaurants nearby” | Yes | "" |
“Best restaurants nearby” | No | None |
Step 2 — LLM Extracts Parameters
When a user sends a query, the UniqueAI schema includes the configured parameters. The LLM attempts to extract matching values from the query.
Example:
User query:
Show me the London policies valid after 2024Extracted parameters:
{
"location": "London",
"date": "2024-01-01"
}Important: The parameter description is only used to guide extraction from the user query. Defining a parameter alone does NOT automatically filter documents. Filtering only happens when the parameter is referenced in a scope rule.
Step 3 — Dynamic Rules Are Evaluated
Dynamic rules reference extracted parameters using:
<toolParameters.parameterName>At search time:
The extracted parameter values are injected into the rule
The rule is compiled into metadata filters
The search only retrieves matching documents
Configuration - Internal Search Tool
Narrow Knowledge Base Scope
Dynamic filtering is configured inside the Knowledge Scope settings.
Administrators can:
Select folders and files
Create advanced filters
Define parameter extraction rules
Configure dynamic metadata filtering

Configuration of Internal Search to narrow scopes
Default Configuration Mode
The default mode provides a structured UI for:
Parameter definitions
Filter rules
Rule groups
A rule is a single filter condition, such as:
location "equals" Zurichprice "greater than" 100
You can define multiple rules and combine them using:
AND → all rules must match
OR → at least one rule must match
A group combines multiple rules into a larger condition. You can create multiple groups and combine those groups with AND/OR as well, allowing you to build more advanced and structured filter logic.

Advanced Filter Configuration
Example Configuration
The following example defines:
a required
locationparameteran optional
dateparameter
The extracted values are then used inside scope rules.
Example Parameters
Parameter | Type | Required | Description |
|---|---|---|---|
location | string | Yes | Extract the location mentioned in the query |
date | date | No | Extract the date mentioned in the query |

Advanced Filter
Example: Location Filtering
The following rule:
location equals <toolParameters.location>means:
location(left side) is metadata stored on documents in the knowledge base<toolParameters.location>is the value extracted from the user query
If:
a document contains metadata:
{
"location": "London"
}and the user asks:
Show me London HR policiesthen:
toolParameters.location = Londonand only documents with:
location = Londonwill be retrieved.
Example: Date Filtering
The following rule:
validAsOf greaterThan <toolParameters.date> || 2000-01-01means:
validAsOfis metadata stored on documentsthe extracted date is used dynamically
if no date can be extracted, the default value is used
Why Defaults Matter
The date parameter is optional.
If no date is found in the user query:
the parameter is not extracted
the fallback value is used instead
Example fallback:
2000-01-01This ensures that the rule still evaluates safely even when the parameter is missing.
Advanced Mode
Advanced Mode allows direct editing of:
the parameter schema
the UniqueQL configuration
This mode is intended for advanced users.
It provides full flexibility but requires knowledge of:
JSON schema configuration
UniqueQL syntax
metadata filtering structure

Example Knowledge Base Metadata
The following example shows a document stored in the knowledge base with metadata attached directly to the file.
Example metadata:
location: BerlinvalidAsOf: 2026-04-30
These metadata fields are what the dynamic filter rules operate on during retrieval.
For example:
the rule path
locationmaps to the document metadata fieldlocationthe rule path
validAsOfmaps to the document metadata fieldvalidAsOf
If a user query contains:
Show me Berlin documents valid after 2026the extracted tool parameters are matched against these metadata values to determine whether the document should be retrieved.
This metadata is configured directly on the documents inside the knowledge base.

Metadata Requirements
Dynamic filters operate on metadata stored in the knowledge base.
This means:
documents must contain the metadata fields referenced in the rules
metadata keys must match the configured rule paths
Example document metadata:
{
"location": "London",
"validAsOf": "2024-01-01"
}Without matching metadata on the documents, dynamic filtering cannot work.
Sequence Diagram Dynamic Filters
