# Meilisearch — Lightning-Fast Open Source Search Engine > Meilisearch is a fast, typo-tolerant, hybrid search engine API with AI-powered semantic search. Drop-in alternative to Algolia and ElasticSearch with simple deployment. ## Install Save in your project root: ## Quick Use ```bash # Docker docker run -d --name meilisearch -p 7700:7700 -e MEILI_MASTER_KEY=your-master-key -v meili-data:/meili_data getmeili/meilisearch:latest # Or single binary curl -L https://install.meilisearch.com | sh ./meilisearch --master-key=your-master-key ``` Open `http://localhost:7700` — built-in search preview UI ready to use. ## Intro **Meilisearch** is a lightning-fast, open-source search engine API that brings typo-tolerant, instant search to your applications. It provides an easy-to-use REST API with features like faceted search, AI-powered hybrid search (combining keyword + semantic), custom ranking rules, and multi-language support — all with millisecond response times. With 57K+ GitHub stars and MIT license, Meilisearch positions itself as a developer-friendly alternative to Algolia (paid) and ElasticSearch (complex), offering 95% of the features with 5% of the configuration complexity. ## What Meilisearch Does - **Instant Search**: Sub-50ms search responses even on large datasets - **Typo Tolerance**: Automatic handling of typos and misspellings - **Faceted Search**: Filter by categories, prices, dates, and custom attributes - **Hybrid Search**: Combine keyword search with AI embeddings for semantic understanding - **Synonyms**: Define synonyms for better search results - **Ranking Rules**: Customizable ranking with business logic - **Multi-Language**: Built-in support for 20+ languages including Chinese, Japanese, Arabic - **Geosearch**: Search by geographic distance and bounding box - **Index Management**: Create, update, and delete indexes with REST API - **API Keys**: Granular access control with scoped API keys ## Architecture ``` ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │ Your App │────▶│ Meilisearch │────▶│ Local Disk │ │ (Search UI) │ │ Engine │ │ (LMDB) │ └──────────────┘ │ (Rust) │ └──────────────┘ └──────────────┘ ``` Meilisearch is a single binary written in Rust. No external dependencies — just a single process that stores data in an embedded LMDB database. ## Self-Hosting ### Docker Compose ```yaml services: meilisearch: image: getmeili/meilisearch:latest ports: - "7700:7700" environment: MEILI_MASTER_KEY: your-master-key-min-16-chars MEILI_ENV: production MEILI_NO_ANALYTICS: "true" volumes: - meili-data:/meili_data restart: unless-stopped volumes: meili-data: ``` ## Basic Usage ### 1. Create Index and Add Documents ```bash # Add documents to an index curl -X POST 'http://localhost:7700/indexes/products/documents' -H "Authorization: Bearer your-master-key" -H "Content-Type: application/json" --data-binary '[ { "id": 1, "name": "iPhone 15 Pro", "price": 999, "brand": "Apple", "tags": ["phone", "premium"] }, { "id": 2, "name": "Samsung Galaxy S24", "price": 899, "brand": "Samsung", "tags": ["phone", "android"] } ]' ``` ### 2. Search ```bash # Simple search curl 'http://localhost:7700/indexes/products/search?q=iphone' -H "Authorization: Bearer your-master-key" # Advanced search with filters curl -X POST 'http://localhost:7700/indexes/products/search' -H "Authorization: Bearer your-master-key" -H "Content-Type: application/json" -d '{ "q": "phone", "filter": "price < 1000 AND brand = "Apple"", "sort": ["price:asc"], "limit": 10, "attributesToHighlight": ["name"] }' ``` ### 3. Typo Tolerance in Action ``` Query: "iphne" → Finds "iPhone" (automatic typo correction) Query: "samsong" → Finds "Samsung" Query: "prroducts" → Finds "products" ``` ## SDK Examples ### JavaScript ```javascript import { MeiliSearch } from 'meilisearch'; const client = new MeiliSearch({ host: 'http://localhost:7700', apiKey: 'your-master-key', }); // Add documents await client.index('products').addDocuments([ { id: 1, name: 'iPhone 15', price: 999 }, ]); // Search const results = await client.index('products').search('iphone', { limit: 10, filter: 'price < 1500', }); ``` ### Python ```python import meilisearch client = meilisearch.Client('http://localhost:7700', 'your-master-key') # Add documents client.index('products').add_documents([ {'id': 1, 'name': 'iPhone 15', 'price': 999} ]) # Search results = client.index('products').search('iphone', { 'limit': 10, 'filter': 'price < 1500' }) ``` ## Key Features ### Hybrid Search (AI + Keyword) ```json { "q": "comfortable running shoes", "hybrid": { "embedder": "openai", "semanticRatio": 0.5 } } ``` Combines traditional keyword matching with AI semantic understanding for best results. ### Faceted Search ```json { "q": "phone", "facets": ["brand", "price_range", "tags"] } ``` Response includes facet counts for building filter UIs. ### Ranking Rules ```json { "rankingRules": [ "words", "typo", "proximity", "attribute", "sort", "exactness", "popularity:desc" ] } ``` ### Instant Search UI Use InstantMeilisearch for React/Vue/vanilla JS: ```jsx import { InstantSearch, SearchBox, Hits } from 'react-instantsearch-dom'; import { instantMeiliSearch } from '@meilisearch/instant-meilisearch'; const searchClient = instantMeiliSearch('http://localhost:7700', 'your-key'); function App() { return ( ); } ``` ## Meilisearch vs Alternatives | Feature | Meilisearch | Typesense | Algolia | ElasticSearch | |---------|------------|-----------|---------|---------------| | Open Source | Yes (MIT) | Yes (GPL) | No | Yes (Elastic/AGPL) | | Setup | Single binary | Single binary | SaaS | Cluster | | Typo tolerance | Built-in | Built-in | Built-in | Plugin | | AI hybrid search | Yes | Yes | Yes | Yes (v8) | | Faceted search | Yes | Yes | Yes | Yes | | Geosearch | Yes | Yes | Yes | Yes | | Language | Rust | C++ | N/A | Java | | RAM per 1M docs | ~1GB | ~1GB | N/A | ~4GB+ | | Pricing | Free | Free | $500+/mo | Free (self-host) | ## 常见问题 **Q: Meilisearch 适合多大的数据集?** A: 适合中小型数据集(几十万到几千万文档)。官方推荐单实例处理 10M 以下文档。对于亿级数据,ElasticSearch 或 Qdrant 更合适。 **Q: 中文搜索效果如何?** A: 非常好。Meilisearch 内置中文分词(jieba),对简体/繁体、混合中英文查询都有良好支持。无需额外配置。 **Q: 和 Algolia 比主要区别?** A: Algolia 是托管服务($$$),Meilisearch 可以自托管(免费)。功能相似,Meilisearch 的搜索速度与 Algolia 相当。对于成本敏感的项目,Meilisearch 是完美替代。 ## 来源与致谢 - GitHub: [meilisearch/meilisearch](https://github.com/meilisearch/meilisearch) — 57K+ ⭐ | MIT - 官网: [meilisearch.com](https://meilisearch.com) --- Source: https://tokrepo.com/en/workflows/929a9b01-352f-11f1-9bc6-00163e2b0d79 Author: AI Open Source