| layout | title | parent | nav_order |
|---|---|---|---|
default |
Chapter 1: Getting Started with Meilisearch |
MeiliSearch Tutorial |
1 |
Welcome to your Meilisearch journey! In this chapter, we'll get Meilisearch up and running and perform your first searches.
# Download the latest binary for your platform
curl -L https://install.meilisearch.com | sh
# Or download specific version
wget https://github.com/meilisearch/meilisearch/releases/download/v1.8.0/meilisearch-linux-amd64
# Make it executable
chmod +x meilisearch-linux-amd64# Pull the official Docker image
docker pull getmeili/meilisearch:v1.8.0
# Run Meilisearch in Docker
docker run -p 7700:7700 getmeili/meilisearch:v1.8.0# Clone the repository
git clone https://github.com/meilisearch/meilisearch.git
cd meilisearch
# Build with Cargo
cargo build --release# Start with default settings
./meilisearch
# Start with custom settings
./meilisearch --http-addr 127.0.0.1:7700 --master-key "your_master_key"# Set environment variables
export MEILI_HTTP_ADDR=127.0.0.1:7700
export MEILI_MASTER_KEY=your_master_key
export MEILI_DB_PATH=./meili_data
export MEILI_ENV=productionCreate a config.toml file:
# Meilisearch configuration file
http_addr = "127.0.0.1:7700"
master_key = "your_master_key"
db_path = "./meili_data"
env = "development"
max_index_size = "100 GiB"Let's create our first index and perform a search:
./meilisearch --master-key="your_master_key"curl -X POST 'http://localhost:7700/indexes' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer your_master_key' \
--data '{
"uid": "movies",
"primaryKey": "id"
}'curl -X POST 'http://localhost:7700/indexes/movies/documents' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer your_master_key' \
--data '[
{
"id": 1,
"title": "The Shawshank Redemption",
"genre": "Drama",
"year": 1994,
"rating": 9.3
},
{
"id": 2,
"title": "The Godfather",
"genre": "Crime",
"year": 1972,
"rating": 9.2
},
{
"id": 3,
"title": "The Dark Knight",
"genre": "Action",
"year": 2008,
"rating": 9.0
}
]'curl 'http://localhost:7700/indexes/movies/search?q=shawshank'Expected Response:
{
"hits": [
{
"id": 1,
"title": "The Shawshank Redemption",
"genre": "Drama",
"year": 1994,
"rating": 9.3,
"_formatted": {
"id": 1,
"title": "<em>The Shawshank Redemption</em>",
"genre": "Drama",
"year": 1994,
"rating": 9.3
}
}
],
"query": "shawshank",
"processingTimeMs": 1,
"limit": 20,
"offset": 0,
"estimatedTotalHits": 1
}hits: Array of matching documentsquery: The search query usedprocessingTimeMs: Time taken to process the search (typically < 1ms)_formatted: Highlighted search terms in resultsestimatedTotalHits: Total number of matches
Let's create a simple test script to experiment with Meilisearch:
#!/bin/bash
# test_meilisearch.sh
MASTER_KEY="your_master_key"
BASE_URL="http://localhost:7700"
# Function to make API calls
api_call() {
curl -s -H "Authorization: Bearer $MASTER_KEY" "$@"
}
echo "Testing Meilisearch..."
# Create index
echo "Creating movies index..."
api_call -X POST "$BASE_URL/indexes" \
-H 'Content-Type: application/json' \
-d '{"uid": "movies", "primaryKey": "id"}'
# Add sample data
echo "Adding movie documents..."
api_call -X POST "$BASE_URL/indexes/movies/documents" \
-H 'Content-Type: application/json' \
-d @- << EOF
[
{"id": 1, "title": "Inception", "director": "Christopher Nolan", "year": 2010},
{"id": 2, "title": "The Matrix", "director": "Wachowski Sisters", "year": 1999},
{"id": 3, "title": "Interstellar", "director": "Christopher Nolan", "year": 2014}
]
EOF
# Test search
echo "Searching for 'matrix'..."
api_call "$BASE_URL/indexes/movies/search?q=matrix"
echo "Searching for 'nolan'..."
api_call "$BASE_URL/indexes/movies/search?q=nolan"-
Port Already in Use
# Find process using port 7700 lsof -i :7700 # Kill the process kill -9 <PID>
-
Permission Denied
# Make binary executable chmod +x ./meilisearch -
Master Key Required
# Always include master key in API calls curl -H "Authorization: Bearer your_master_key" ...
Verify Meilisearch is running:
curl http://localhost:7700/healthExpected Response:
{"status": "available"}In the next chapter, we'll explore document management - how to add, update, and delete documents in your Meilisearch indexes.
- ✅ Installed Meilisearch using binary or Docker
- ✅ Configured basic settings and master key
- ✅ Created your first index
- ✅ Added documents and performed searches
- ✅ Understood search response structure
- ✅ Created a test script for experimentation
Key Takeaways:
- Meilisearch provides sub-millisecond search responses
- RESTful API makes integration straightforward
- Documents are immediately searchable after indexing
- Master key authentication is required for write operations
Most teams struggle here because the hard part is not writing more code, but deciding clear boundaries for meilisearch, your_master_key, movies so behavior stays predictable as complexity grows.
In practical terms, this chapter helps you avoid three common failures:
- coupling core logic too tightly to one implementation path
- missing the handoff boundaries between setup, execution, and validation
- shipping changes without clear rollback or observability strategy
After working through this chapter, you should be able to reason about Chapter 1: Getting Started with Meilisearch as an operating subsystem inside MeiliSearch Tutorial: Lightning Fast Search Engine, with explicit contracts for inputs, state transitions, and outputs.
Use the implementation notes around title, year, curl as your checklist when adapting these patterns to your own repository.
Under the hood, Chapter 1: Getting Started with Meilisearch usually follows a repeatable control path:
- Context bootstrap: initialize runtime config and prerequisites for
meilisearch. - Input normalization: shape incoming data so
your_master_keyreceives stable contracts. - Core execution: run the main logic branch and propagate intermediate state through
movies. - Policy and safety checks: enforce limits, auth scopes, and failure boundaries.
- Output composition: return canonical result payloads for downstream consumers.
- Operational telemetry: emit logs/metrics needed for debugging and performance tuning.
When debugging, walk this sequence in order and confirm each stage has explicit success/failure conditions.
Use the following upstream sources to verify implementation details while reading this chapter:
- View Repo
Why it matters: authoritative reference on
View Repo(github.com). - AI Codebase Knowledge Builder
Why it matters: authoritative reference on
AI Codebase Knowledge Builder(github.com).
Suggested trace strategy:
- search upstream code for
meilisearchandyour_master_keyto map concrete implementation paths - compare docs claims against actual runtime/config code before reusing patterns in production