---
title: "Metadata Search"
description: "Filter and find notes by their YAML frontmatter — status, type, tags, priority, confidence, custom fields, and more."
canonical_url: "https://docs.basicmemory.com/concepts/metadata-search"
---
# Metadata Search

> Filter and find notes by their YAML frontmatter — status, type, tags, priority, confidence, custom fields, and more.

Every note in Basic Memory has YAML frontmatter at the top. Metadata search lets you find notes by those fields — status, type, tags, custom fields, anything you put there. It's how you ask things like *"show me all in-progress specs tagged security"* or *"find decisions made in the last quarter with priority high or critical"* without scanning text.

<docs-video alt="Filtering notes by frontmatter fields in Structured search" poster="/videos/posters/docs-metadata-search.png" src="https://docs.basicmemory.com/videos/docs-metadata-search.mp4">



</docs-video>

Metadata search is a parameter on the same [`bm_search`](https://docs.basicmemory.com/reference/mcp-tools-reference#bm_search) tool you use for text and [semantic search](https://docs.basicmemory.com/concepts/semantic-search). You can use it on its own, or combine it with a text query and tag filters.

<tip>

Frontmatter is structured data. The richer your frontmatter, the sharper your search. A note with `type: meeting`, `status: open`, `priority: high`, and `attendees: [...]` is reachable from many more angles than one with just a title.

</tip>

<note>

Observation categories such as `[decision]`, `[rule]`, or `[follow-up]` are not frontmatter fields — see [Searching observations by category](#searching-observations-by-category) below instead of `filters`.

</note>

---

## What's in your frontmatter

Anything you put in the YAML block at the top of a note becomes searchable:

```markdown
---
title: Auth Design
type: spec
tags: [security, oauth]
status: in-progress
priority: high
confidence: 0.85
---
```

Use `filters` for tags, status, and custom fields; `note_types` filters note types. You can also reach into nested objects with **dot notation** — `schema.confidence` targets the `confidence` key inside a `schema` object.

<note>

Field **names** must match the chars `A-Z a-z 0-9 _ -` (with `.` for nesting). Field **values** can be strings, numbers, booleans, dates, or lists.

</note>

---

## Filter syntax

`filters` is a JSON object. Each key is a field name; each value is either a literal (for equality) or an operator object.

Multiple top-level keys combine with **AND** — all conditions must match.

### Equality

```json
{"status": "in-progress"}
```

### Array contains (all values present)

For list-valued fields like `tags`, an array means *"all of these"*:

```json
{"tags": ["security", "oauth"]}
```

### `$in` — any of

Match if the field equals **any** value in the list. This is how you express OR within a single field:

```json
{"priority": {"$in": ["high", "critical"]}}
```

### Comparison — `$gt`, `$gte`, `$lt`, `$lte`

Numeric or lexicographic comparison; boundaries on `$gte`/`$lte` are inclusive.

```json
{"confidence": {"$gt": 0.7}}
{"score": {"$lte": 100}}
```

### `$between` — inclusive range

Both ends included; the value must be exactly two items:

```json
{"confidence": {"$between": [0.5, 0.9]}}
```

### Several operators on one field

Operators in one object AND together, so a range can be written the way you'd write it in MongoDB:

```json
{"started": {"$gte": "2026-01-01", "$lt": "2026-02-01"}}
```

### `$contains` — array contains

The operator form of the array filter above. Takes one value or a list, all of which must be present:

```json
{"tags": {"$contains": "security"}}
{"tags": {"$contains": ["security", "oauth"]}}
```

### `$exists` and null — present or missing

`$exists: true` matches notes that have a non-null value at that key; `$exists: false` matches notes where it's missing or null. Equality with `null` is the same as `$exists: false`:

```json
{"owner": {"$exists": true}}
{"owner": null}
```

### Nested fields (dot notation)

```json
{"schema.confidence": {"$gt": 0.7}}
```

### Operator spelling

The leading `$` is optional: `{"priority": {"in": ["high"]}}` and `{"confidence": {"gte": 0.7}}` work the same as `$in` and `$gte`. An unknown operator is refused with a list of the valid ones.

### Operator reference

<table>
<thead>
  <tr>
    <th>
      Operator
    </th>
    
    <th>
      Value
    </th>
    
    <th>
      Behavior
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <em>
        (scalar)
      </em>
    </td>
    
    <td>
      string / number / bool / date
    </td>
    
    <td>
      Exact match
    </td>
  </tr>
  
  <tr>
    <td>
      <em>
        (array)
      </em>
    </td>
    
    <td>
      list of scalars
    </td>
    
    <td>
      All values must be present (for list fields)
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        $in
      </code>
    </td>
    
    <td>
      non-empty list
    </td>
    
    <td>
      Any of
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        $gt
      </code>
      
      , <code>
        $gte
      </code>
      
      , <code>
        $lt
      </code>
      
      , <code>
        $lte
      </code>
    </td>
    
    <td>
      number or string
    </td>
    
    <td>
      Comparison (gte/lte inclusive); strings compare lexicographically — dates as ISO strings
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        $between
      </code>
    </td>
    
    <td>
      <code>
        [min, max]
      </code>
    </td>
    
    <td>
      Inclusive range, exactly 2 values
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        $contains
      </code>
    </td>
    
    <td>
      value or non-empty list
    </td>
    
    <td>
      All values present in a list field
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        $exists
      </code>
    </td>
    
    <td>
      <code>
        true
      </code>
      
       / <code>
        false
      </code>
    </td>
    
    <td>
      Has a non-null value / is missing or null
    </td>
  </tr>
  
  <tr>
    <td>
      <em>
        (null)
      </em>
    </td>
    
    <td>
      <code>
        null
      </code>
    </td>
    
    <td>
      Missing or explicitly null (same as <code>
        $exists: false
      </code>
      
      )
    </td>
  </tr>
</tbody>
</table>

<note>

Several operators in one object AND together (`{"$gt": 0.5, "$lt": 1.0}`), and the `$` prefix is optional. These shapes were added in [v0.24](https://docs.basicmemory.com/whats-new/v0-24); earlier versions allowed one operator per field and required the `$`. There's no `$ne`, `$nin`, or `$regex`; combine multiple top-level keys with AND, and use `$in` for OR within a field. `null` is accepted only as an equality value, not inside `$in`, `$between`, comparisons, or lists.

</note>

---

## Tags and note types

Use `filters={"tags": ["security"], "status": "draft"}` for frontmatter fields and `note_types=["spec", "decision"]` for note types. The old top-level `tags` and `status` MCP parameters are removed.

```python
bm_search(filters={"tags": ["security", "oauth"]})
bm_search(note_types=["spec", "decision"], filters={"status": "draft"})
```

---

## Combining with text and semantic search

Metadata filters compose with everything else `bm_search` does. The text query and the filters apply together (AND):

```python
# OAuth-related notes that are still in progress
bm_search("OAuth", filters={"status": "in-progress"})

# Pure metadata — no text query
bm_search(filters={"type": "spec", "status": "active"})

# Text + tag shortcut + metadata
bm_search("auth", filters={"tags": ["security"], "priority": {"$in": ["high", "critical"]}})
```

See [Semantic Search](https://docs.basicmemory.com/concepts/semantic-search) for how text and vector modes interact.

---

## From the CLI

The CLI retains its command names and shortcut flags:

```bash
# Simple equality
bm tool search-notes "" --meta status=draft

# Multiple --meta flags AND together
bm tool search-notes "" --meta status=active --meta priority=high

# Full JSON filter
bm tool search-notes "" --filter '{"confidence": {"$between": [0.3, 0.8]}}'

# Convenience shortcuts
bm tool search-notes "auth" --tag security --tag oauth --status draft --type spec
```

See [CLI Reference](https://docs.basicmemory.com/reference/cli-reference#bm-tool-search-notes) for every flag.

---

## Worked examples

Given a few notes like this:

```markdown
---
title: Auth Design
type: spec
status: in-progress
priority: high
tags: [security, oauth]
confidence: 0.85
---
```

```markdown
---
title: Search Redesign
type: spec
status: planning
priority: medium
tags: [search, performance]
confidence: 0.6
---
```

<table>
<thead>
  <tr>
    <th>
      You want…
    </th>
    
    <th>
      <code>
        filters
      </code>
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      All in-progress specs
    </td>
    
    <td>
      <code>
        {"status": "in-progress", "type": "spec"}
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      Specs with confidence above 0.7
    </td>
    
    <td>
      <code>
        {"type": "spec", "confidence": {"$gt": 0.7}}
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      Anything high or critical priority
    </td>
    
    <td>
      <code>
        {"priority": {"$in": ["high", "critical"]}}
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      Specs in confidence range <span>
        0.5, 0.9
      </span>
    </td>
    
    <td>
      <code>
        {"type": "spec", "confidence": {"$between": [0.5, 0.9]}}
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      Decisions since April
    </td>
    
    <td>
      <code>
        {"type": "decision", "date": {"$gte": "2026-04-01"}}
      </code>
      
       — dates compare as ISO strings
    </td>
  </tr>
  
  <tr>
    <td>
      Notes tagged both <code>
        security
      </code>
      
       AND <code>
        oauth
      </code>
    </td>
    
    <td>
      <code>
        {"tags": ["security", "oauth"]}
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      "OAuth" matches in still-open work
    </td>
    
    <td>
      use <code>
        bm_search("OAuth", filters={"status": "in-progress"})
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      Anything with nested <code>
        schema.confidence
      </code>
      
       ≥ 0.7
    </td>
    
    <td>
      <code>
        {"schema.confidence": {"$gte": 0.7}}
      </code>
    </td>
  </tr>
</tbody>
</table>

---

## Searching observations by category

Observation categories (`- [decision] ...`, `- [rule] ...`) live on observations, not in frontmatter — so they get their own filter, `categories`, instead of `filters`:

```python
# All decision observations, anywhere
bm_search(categories=["decision"])

# Decisions mentioning auth
bm_search("auth", categories=["decision"], items=["observation"])
```

Matching is exact, and when you pass `categories` without `items`, results default to observations. From the CLI:

```bash
bm tool search-notes "auth" --entity-type observation --category decision
```

---

## Searching by valid time

Frontmatter dates such as `date` or `due_date` describe a whole note. When individual facts have their own dates, put the date on the observation with a valid-time qualifier (new in [v0.24](https://docs.basicmemory.com/whats-new/v0-24)):

```markdown
- [decision] @effective[2026-06-10,2026-07-27) Cache layer uses Redis.
- [decision] @effective:2026-07-27 Cache layer uses Memcached.
```

`bm_search` has three filters for that authored time. They're about what the note *says* was true, separate from `since`, which filters by when content was indexed:

<table>
<thead>
  <tr>
    <th>
      Parameter
    </th>
    
    <th>
      Value
    </th>
    
    <th>
      Matches
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        valid_at
      </code>
    </td>
    
    <td>
      A date (<code>
        "2026-07-01"
      </code>
      
      ) or an instant (<code>
        "2026-07-01T09:00:00Z"
      </code>
      
      )
    </td>
    
    <td>
      Observations whose valid range contains it
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        valid_overlaps
      </code>
    </td>
    
    <td>
      A range literal: <code>
        "[2026-06-01,2026-07-01)"
      </code>
      
      , <code>
        "(,2026-07-27]"
      </code>
      
      , <code>
        "[2026-06-10,)"
      </code>
    </td>
    
    <td>
      Observations whose valid range overlaps it
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        time_kind
      </code>
    </td>
    
    <td>
      <code>
        effective
      </code>
      
      , <code>
        valid
      </code>
      
      , <code>
        occurred
      </code>
      
      , <code>
        due
      </code>
      
      , or <code>
        mentioned
      </code>
    </td>
    
    <td>
      Only that kind of qualifier; works on its own too
    </td>
  </tr>
</tbody>
</table>

```python
# What cache decision was in effect on July 1st?
bm_search("cache", valid_at="2026-07-01", time_kind="effective")

# Everything due during Q3
bm_search(valid_overlaps="[2026-07-01,2026-10-01)", time_kind="due")
```

- `valid_at` and `valid_overlaps` can't be combined in one search.
- Observations without a qualifier are excluded from any valid-time search — an undated fact makes no claim about when it holds. Drop the filter to search dated and undated content together.
- Results are observation-level, each carrying the assertion that matched, because one note can hold several dated facts that disagree.
- Calendar dates and instants are separate: a date query matches date ranges, an instant query matches instant ranges. A timestamp without an offset is read as UTC.
- A malformed filter is refused with an error rather than ignored.
- Valid-time filters compose with text, vector, hybrid, and metadata filters.
- These filters are MCP and API parameters; `bm tool search-notes` doesn't have flags for them.

The authoring syntax is covered in [Observations and Relations](https://docs.basicmemory.com/concepts/observations-and-relations#when-a-fact-holds-valid-time).

---

## Type handling

- **Strings** match exactly (case-sensitive).
- **Numbers** — comparison operators detect numeric values automatically, so `"0.5"` and `0.5` compare the same way.
- **Booleans** are compared as the strings `"True"` and `"False"`.
- **Dates and datetimes** are normalized to ISO strings.
- **Missing fields** don't match equality, comparison, or list filters. To find notes that lack a field, use `{"field": null}` or `{"field": {"$exists": false}}`.

---

## Limits and caveats

- **AND only at the top level.** Combine multiple keys to AND; use `$in` for OR within a single field. There's no top-level `$or`.
- **No full-text matching inside metadata.** Use exact, range, or `$in` matching — for free-text search across note bodies, use [text or semantic search](https://docs.basicmemory.com/concepts/semantic-search).
- **Lists in filters must be non-empty.** `{"tags": []}` is rejected.
- **$between requires exactly two values.**
- **No $ne, $nin, $regex.** They're not in the operator set.
- **Markdown notes only.** Non-Markdown files (PDFs, images) aren't matched by metadata filters.

---

## Related

- [Search Notes (MCP Tools Reference)](https://docs.basicmemory.com/reference/mcp-tools-reference#bm_search)
- [Semantic Search](https://docs.basicmemory.com/concepts/semantic-search) — text, vector, and hybrid modes
- [Schema System](https://docs.basicmemory.com/concepts/schema-system) — make required frontmatter fields explicit
- [Knowledge Format](https://docs.basicmemory.com/concepts/knowledge-format) — the structure of a note
- [CLI: `bm tool search-notes`](https://docs.basicmemory.com/reference/cli-reference#bm-tool-search-notes)


## Sitemap

See the full [sitemap](https://docs.basicmemory.com/sitemap.md) for all pages.
