---
sidebar_position: 5
title: search_catalog
description: Fuzzy search across databases, schemas, tables, columns, and shares
---

# search_catalog

Search the catalog for databases, schemas, tables, columns, and shares using fuzzy matching.

## Description

The `search_catalog` tool performs fuzzy search across your entire MotherDuck catalog. It finds matching objects by name using partial matching, supporting underscores, dots, and multi-word queries. This is useful for discovering available data when you don't know exact names.

The search uses Jaro-Winkler similarity scoring and returns results ranked by relevance. Results are limited per category to provide a balanced view across different object types.

## Input Parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `query` | string | Yes | Search term to find in object names (supports partial matching, underscores, dots) |
| `object_types` | string[] | No | Filter results to specific types: `"database"`, `"schema"`, `"table"`, `"column"`, `"share"` |

## Output Schema

```json
{
  "success": boolean,
  "query": string,               // Search query used
  "resultCount": number,         // Total results found
  "results": [                   // Search results (on success)
    {
      "type": "database" | "schema" | "table" | "column" | "share",
      "name": string,            // Object name
      "fullyQualifiedName": string, // Full path (e.g., "db.schema.table.column")
      "database": string | null, // Database (null for shares)
      "schema": string | null,   // Schema (null for databases/shares)
      "table": string | null,    // Table (only for columns)
      "dataType": string | null, // Data type (columns) or URL (shares)
      "comment": string | null,  // Object comment if set
      "relevanceScore": number   // Match score 0-1 (higher is better)
    }
  ],
  "error": string,               // Error message (on failure)
  "errorType": string            // Error type (on failure)
}
```

## Result Limits

Results are limited per object type to provide balanced coverage:
- Shares: 10 results
- Columns: 40 results
- Tables: 30 results
- Schemas: 20 results
- Databases: 20 results

Maximum total results: 100

## Example Usage

**Search for tables with "sales" in the name:**

```text
Find all tables related to sales data
```

The AI assistant will call the tool with:

```json
{
  "query": "sales"
}
```

**Search only for columns:**

```text
Find columns containing "email"
```

```json
{
  "query": "email",
  "object_types": ["column"]
}
```

**Search with qualified name:**

```text
Find anything matching analytics.events
```

```json
{
  "query": "analytics.events"
}
```

## Success Response Example

```json
{
  "success": true,
  "query": "sales",
  "resultCount": 8,
  "results": [
    {
      "type": "table",
      "name": "sales_data",
      "fullyQualifiedName": "analytics.main.sales_data",
      "database": "analytics",
      "schema": "main",
      "table": null,
      "dataType": null,
      "comment": "Daily sales transactions",
      "relevanceScore": 0.95
    },
    {
      "type": "table",
      "name": "monthly_sales",
      "fullyQualifiedName": "analytics.main.monthly_sales",
      "database": "analytics",
      "schema": "main",
      "table": null,
      "dataType": null,
      "comment": null,
      "relevanceScore": 0.89
    },
    {
      "type": "column",
      "name": "total_sales",
      "fullyQualifiedName": "analytics.main.revenue.total_sales",
      "database": "analytics",
      "schema": "main",
      "table": "revenue",
      "dataType": "DECIMAL(18,2)",
      "comment": "Total sales amount",
      "relevanceScore": 0.87
    },
    {
      "type": "share",
      "name": "regional_sales_share",
      "fullyQualifiedName": "regional_sales_share",
      "database": "regional_sales_share",
      "schema": null,
      "table": null,
      "dataType": "md:_share/org123/regional_sales_share",
      "comment": null,
      "relevanceScore": 0.82
    }
  ]
}
```

## Error Response Example

```json
{
  "success": false,
  "error": "Search query cannot be empty",
  "errorType": "ValidationError"
}
```
