> For the complete documentation index, see [llms.txt](https://docs.stackai.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.stackai.com/technical-reference/files-knowledge-and-retrieval/metadata-schemas-and-search-filters.md).

# Metadata Schemas and Search Filters

Metadata filters narrow retrieval using file attributes. Define consistent fields and values so a question can select the intended documents.

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSQ1Sgy933krTyK0S4JpP%2Fuploads%2F1tPGm5vYo9IgKi6Evw2H%2FG040.mp4?alt=media&token=b410bd8d-5fbf-4009-8196-4a332053b372>" %}

## Before you begin

A knowledge-base metadata schema and populated values on the relevant files.

## Key concepts

| Term             | Definition                                                                                                                                                  |
| ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Metadata         | Structured attributes associated with a source file or record. Consistent field names and types make filtering predictable.                                 |
| Schema           | A definition of fields, types, required values, and supported constraints. Use it to validate the shape of data; it does not establish factual correctness. |
| Source selection | The files or folders included in an operation. An empty optional selection can mean the whole knowledge base rather than no files.                          |

## Configuration options

| Option | Purpose                                                         | Behavior                                                     |
| ------ | --------------------------------------------------------------- | ------------------------------------------------------------ |
| Filter | A condition that narrows the records eligible for an operation. | A filter can exclude relevant content before ranking occurs. |

## Filter searches with metadata

1. Inspect the available metadata fields and their types.

![Use the Metadata tab to assign consistent properties to source files.](https://content.gitbook.com/content/SQ1Sgy933krTyK0S4JpP/blobs/XRE3JA9nJMOeO4EMR2fS/assets/g040-g040-01-sales.png)

Use the Metadata tab to assign consistent properties to source files.

2. Configure the filter or metadata-aware query using those fields.
3. Review the resulting source set and retrieved passages.

The query returns evidence from documents that meet the supported filter conditions.

## Behavior and limitations

Use fields defined in the knowledge-base metadata schema and values actually assigned to files. Mentioning a field in a question does not create it or guarantee a valid filter. Check the returned source set when using natural-language filtering. Metadata filters narrow content; they do not replace permission controls.

## Related resources

[Metadata filters](https://docs.stackai.com/guides-and-quickstarts/knowledge-and-retrieval/metadata-filters.md)

[File Inputs, Supported Formats, and Size Limits](https://docs.stackai.com/technical-reference/files-knowledge-and-retrieval/file-inputs-supported-formats-and-size-limits.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.stackai.com/technical-reference/files-knowledge-and-retrieval/metadata-schemas-and-search-filters.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
