Metadata Filters

Optimize your similarity searches with metadata filters. Our platform allows you to attach metadata as key-value pairs to your Memory Stores and then refine your search queries with filter expressions. This means more targeted results.

Using the Visual Editor to Filter Metadata

Memory stores have two different filter modes, the first is a Visual Editor where you can filter data based on a specific metadata field. For example, if your memory store had client metadata and you wanted to filter on an input client_name, you could use the following liquid syntax in the metadata filter:

Visual Editor

Visual Editor

Using the Code Editor to Filter Metadata

For more complex use cases, you can use the code editor which uses MongoDB's query and projection operators. While we support a comprehensive range of these operators, here are some of the most commonly used ones:

$eq - Equal to (for numbers, strings, booleans)
$ne - Not equal to (for numbers, strings, booleans)
$gt - Greater than (for numbers)
$gte - Greater than or equal to (for numbers)
$lt - Less than (for numbers)
$lte - Less than or equal to (for numbers)
$in - In array (for strings or numbers)
$nin - Not in array (for strings or numbers)

When your metadata involves a list of strings, like "genres": ["thriller", "mystery"], the Memory Store accepts both genres as valid.

If you need help setting up your Memory Store and metadata filters, please reach out to us - we are here to help.