# 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 } }]
}
```


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mindplug.io/api/query/using-metadata-filters.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
