> ## Documentation Index
> Fetch the complete documentation index at: https://www.meilisearch.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Meilisearch CLI quick start

> Get started with Meilisearch from your terminal using the meili command line tool in 5 minutes.

This guide walks you through setting up Meilisearch with `meili`, the Meilisearch command line tool. `meili` works with Meilisearch Cloud projects and with self-hosted instances.

## Prerequisites

* A Meilisearch instance ([Cloud](https://cloud.meilisearch.com) or [self-hosted](https://www.meilisearch.com/docs/resources/self_hosting/getting_started/quick_start.md))
* Node.js 22 or later, only if you install the CLI with npm

## 1. Install the CLI

> [tab] npm
>
> ```bash theme={null}
> npm install -g @meilisearch/cli
> ```

> [tab] Homebrew
>
> ```bash theme={null}
> brew install meilisearch/tap/meili
>
> # to upgrade
> brew update && brew upgrade meilisearch/tap/meili
> ```

> [tab] Install script
>
> ```bash theme={null}
> curl -fsSL https://raw.githubusercontent.com/meilisearch/cli/main/scripts/install.sh | sh
> ```
>
> The script works on macOS and Linux. Run it again to update the CLI.

Check the installation:

```bash theme={null}
meili version
```

## 2. Connect to Meilisearch

The CLI stores your projects in a config file, `~/.config/meili/config.json` by default. Each project has a name, a URL, and an API key.

> [tab] Meilisearch Cloud
>
> Log in to Meilisearch Cloud in your browser, then add your Cloud projects to the config file:
>
> ```bash theme={null}
> meili auth login
> meili config sync-with-cloud --all
> ```
>
> When you are an admin of the project's team, the CLI also saves the project's master key. Otherwise, the CLI saves the project without an API key. Ask an admin of the team for an API key, then add it to the config file:
>
> ```bash theme={null}
> meili config update --project PROJECT_NAME --project-api-key YOUR_API_KEY
> ```

> [tab] Self-hosted
>
> Add your instance to the config file:
>
> ```bash theme={null}
> meili config set --project local \
>   --project-url http://localhost:7700 \
>   --project-api-key YOUR_API_KEY
> ```

List the projects of the config file:

```bash theme={null}
meili config list
```

Every command takes the project name with `--project` (or `-p`). Check that the instance is available:

```bash theme={null}
meili health --project local
# status  available
```

## 3. Add documents

Create a `movies.json` file:

```bash theme={null}
cat > movies.json << 'EOF'
[
  { "id": 1, "title": "The Matrix", "genres": ["Action", "Sci-Fi"], "year": 1999 },
  { "id": 2, "title": "Inception", "genres": ["Action", "Thriller"], "year": 2010 },
  { "id": 3, "title": "Interstellar", "genres": ["Drama", "Sci-Fi"], "year": 2014 }
]
EOF
```

Add the documents to the `movies` index (`--index` or `-i`):

```bash theme={null}
meili document add --project local --index movies --file movies.json --wait
```

Meilisearch creates the `movies` index if it does not exist. Adding documents is an [asynchronous operation](https://www.meilisearch.com/docs/capabilities/indexing/tasks_and_batches/async_operations.md): without `--wait`, the CLI prints the task and returns at once. `--wait` follows the task until indexing is complete, then prints the final task.

## 4. Search

```bash theme={null}
meili search --project local --index movies --q matrix
```

The CLI prints the results as a table:

```text theme={null}
Showing 1 of about 1
query matrix • processingTimeMs 1 • limit 20 • offset 0

ID  TITLE       GENRES          YEAR
1   The Matrix  Action, Sci-Fi  1999
```

Add `--json` to print the JSON response of Meilisearch instead.

## 5. Search with filters

First, configure filterable attributes:

```bash theme={null}
meili settings update --project local --index movies \
  --filterable-attributes genres,year --wait
```

Then search with filters:

```bash theme={null}
meili search --project local --index movies \
  --filter 'genres = "Sci-Fi" AND year > 2000'
```

Without `--q`, Meilisearch runs a placeholder search and returns all documents that match the filter, here `Interstellar`.

## Full example

```bash theme={null}
# Connect to your instance
meili config set --project local \
  --project-url http://localhost:7700 \
  --project-api-key YOUR_API_KEY

# Add documents
meili document add -p local -i movies --file movies.json --wait

# Search
meili search -p local -i movies --q inter
```

## Explore the commands

`meili --help` lists every command. Add `--help` to any command to see its flags and examples:

```bash theme={null}
meili --help
meili search --help
```

`meili schema` describes every command as JSON. `meili schema --command <name>` describes one command in full, with its flags, the Meilisearch routes it calls, and examples. Scripts and AI agents can use it to discover the commands:

```bash theme={null}
meili schema
meili schema --command search
```

## Next steps

> [card] [Full-text search](https://www.meilisearch.com/docs/capabilities/full_text_search/relevancy/relevancy.md)
>
> Configure ranking and relevancy

> [card] [Filtering](https://www.meilisearch.com/docs/capabilities/filtering_sorting_faceting/getting_started.md)
>
> Add filters and facets

> [card] [AI-powered search](https://www.meilisearch.com/docs/capabilities/hybrid_search/getting_started.md)
>
> Add semantic search

> [card] [API reference](https://www.meilisearch.com/docs/reference/api/search/search-with-post.md)
>
> Explore all search parameters

## Resources

* [Meilisearch CLI on GitHub](https://github.com/meilisearch/cli)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.