# garden.engram.searchMemories

> Published by [hailey.at](https://lexicon.garden/identity/did:plc:oisofpd7lj26yvgiivf3lxsi)

✓ This is the authoritative definition for this NSID.

## Links

- [View on Lexicon Garden](https://lexicon.garden/lexicon/did:plc:oisofpd7lj26yvgiivf3lxsi/garden.engram.searchMemories)
- [Documentation](https://lexicon.garden/lexicon/did:plc:oisofpd7lj26yvgiivf3lxsi/garden.engram.searchMemories/docs)
- [Examples](https://lexicon.garden/lexicon/did:plc:oisofpd7lj26yvgiivf3lxsi/garden.engram.searchMemories/examples)

## Definitions

### `garden.engram.searchMemories`

**Type**: `query`

Vector search over a space's memories. The caller embeds its query with the space's model and query prefix. Requires a space credential for the space, presented with an HTTP message signature whose audience is this service's DID.

#### Parameters

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `author` | `string` (did) | No | Only memories written by this DID. |
| `limit` | `integer` | No |  |
| `model` | `string` | Yes | Must match the space's model. |
| `modelDigest` | `string` | Yes | Must match the space's model digest. |
| `q` | `string` | No | The query's text. Optional and not used for ranking yet; kept for keyword search later. |
| `since` | `string` (datetime) | No | Only memories created at or after this time. |
| `space` | `string` | Yes | The space URI. |
| `tags` | `array` | No | Only memories carrying every one of these tags. |
| `vector` | `string` | Yes | The query's vector: little-endian IEEE half precision, base64url-encoded without padding. |

#### Output

**Encoding**: `application/json`

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `approximate` | `boolean` | No | Set when the index couldn't re-rank in time, so results are ranked by a coarser comparison and may be less precise. |
| `memories` | `array` | Yes |  |

#### Errors

- **UnknownSpace**: This service does not index the space.
- **NoModel**: The space's authority hasn't declared an embedding model.
- **ModelMismatch**: The query's model isn't the space's model. Re-read the space's config.
- **IndexLoading**: The space's index is loading. Retry shortly.
- **RateLimitExceeded**: Too many searches for this space.

## Raw Schema

```json
{
  "$type": "com.atproto.lexicon.schema",
  "defs": {
    "main": {
      "description": "Vector search over a space's memories. The caller embeds its query with the space's model and query prefix. Requires a space credential for the space, presented with an HTTP message signature whose audience is this service's DID.",
      "errors": [
        {
          "description": "This service does not index the space.",
          "name": "UnknownSpace"
        },
        {
          "description": "The space's authority hasn't declared an embedding model.",
          "name": "NoModel"
        },
        {
          "description": "The query's model isn't the space's model. Re-read the space's config.",
          "name": "ModelMismatch"
        },
        {
          "description": "The space's index is loading. Retry shortly.",
          "name": "IndexLoading"
        },
        {
          "description": "Too many searches for this space.",
          "name": "RateLimitExceeded"
        }
      ],
      "output": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "approximate": {
              "description": "Set when the index couldn't re-rank in time, so results are ranked by a coarser comparison and may be less precise.",
              "type": "boolean"
            },
            "memories": {
              "items": {
                "ref": "garden.engram.defs#memoryView",
                "type": "ref"
              },
              "type": "array"
            }
          },
          "required": [
            "memories"
          ],
          "type": "object"
        }
      },
      "parameters": {
        "properties": {
          "author": {
            "description": "Only memories written by this DID.",
            "format": "did",
            "type": "string"
          },
          "limit": {
            "default": 10,
            "maximum": 50,
            "minimum": 1,
            "type": "integer"
          },
          "model": {
            "description": "Must match the space's model.",
            "type": "string"
          },
          "modelDigest": {
            "description": "Must match the space's model digest.",
            "type": "string"
          },
          "q": {
            "description": "The query's text. Optional and not used for ranking yet; kept for keyword search later.",
            "maxLength": 4000,
            "type": "string"
          },
          "since": {
            "description": "Only memories created at or after this time.",
            "format": "datetime",
            "type": "string"
          },
          "space": {
            "description": "The space URI.",
            "type": "string"
          },
          "tags": {
            "description": "Only memories carrying every one of these tags.",
            "items": {
              "type": "string"
            },
            "maxLength": 16,
            "type": "array"
          },
          "vector": {
            "description": "The query's vector: little-endian IEEE half precision, base64url-encoded without padding.",
            "maxLength": 43000,
            "type": "string"
          }
        },
        "required": [
          "space",
          "vector",
          "model",
          "modelDigest"
        ],
        "type": "params"
      },
      "type": "query"
    }
  },
  "id": "garden.engram.searchMemories",
  "lexicon": 1
}
```
