> For the complete documentation index, see [llms.txt](https://docs.mindplug.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mindplug.io/api/query/using-metadata-filters.md).

# Using Metadata Filters

### Supported metadata types

You can associate a metadata payload with each vector in an index, as key-value pairs in a JSON object where keys are strings and values are one of:

* String
* Number (integer or floating point, gets converted to a 64 bit floating point)
* Booleans (true, false)
* List of String

The metadata filters can be combined with AND and OR:

* `$eq` - Equal to *(number, string, boolean)*
* `$ne` - Not equal to *(number, string, boolean)*
* `$gt` - Greater than *(number)*
* `$gte` - Greater than or equal to *(number)*
* `$lt` - Less than *(number)*
* `$lte` - Less than or equal to *(number)*
* `$in` - In array *(string or number)*
* `$nin` - Not in array *(string or number)*

#### Using arrays of strings as metadata values or as metadata filters

A vector with metadata payload...

```json
{ "genre": ["comedy", "documentary"] }
```

...means the `"genre"` takes on both values.

For example, queries with the following filters will match the vector:

```json
{"genre":"comedy"}

{"genre": {"$in":["documentary","action"]}}

{"$and": [{"genre": "comedy"}, {"genre":"documentary"}]}
```

Queries with the following filter will **not** match the vector:

```json
{ "$and": [{ "genre": "comedy" }, { "genre": "drama" }] }
```

And queries with the following filters will **not** match the vector because they are invalid. They will result in a query compilation error:

```
# INVALID QUERY:
{"genre": ["comedy", "documentary"]}
```

```
# INVALID QUERY:
{"genre": {"$eq": ["comedy", "documentary"]}}
```

#### More example filter expressions

A comedy, documentary, or drama:

```json
{
  "genre": { "$in": ["comedy", "documentary", "drama"] }
}
```

A drama from 2020:

```json
{
  "genre": { "$eq": "drama" },
  "year": { "$gte": 2020 }
}
```

A drama from 2020 (equivalent to the previous example):

```json
{
  "$and": [{ "genre": { "$eq": "drama" } }, { "year": { "$gte": 2020 } }]
}
```

A drama or a movie from 2020:

```json
{
  "$or": [{ "genre": { "$eq": "drama" } }, { "year": { "$gte": 2020 } }]
}
```
