Skip to main content
Back to blog

Why I use Meilisearch instead of Elasticsearch

·4 min readDatabases

I ran Elasticsearch for a project once. It worked, but the operational overhead was brutal. A JVM-based system that wanted gigabytes of RAM, a cluster architecture designed for massive scale I did not need, and a query DSL that required its own learning curve. When I found Meilisearch, I switched and never looked back.

What Meilisearch is

Meilisearch is an open-source search engine built in Rust. It is designed for end-user-facing search: the kind where someone types in a search box and expects instant, relevant, typo-tolerant results. Think of the search experience on sites like Algolia-powered documentation or e-commerce product search.

It is fast. Queries return in single-digit milliseconds. It handles typos automatically. It ranks results intelligently. And it does all of this out of the box with almost zero configuration.

The Elasticsearch problem

Elasticsearch is incredibly powerful. It can do full-text search, analytics, log aggregation, geospatial queries, and more. The problem is that power comes with complexity:

Resource usage. Elasticsearch runs on the JVM and wants at least 2-4GB of RAM for a small deployment. Meilisearch runs as a single binary and handles millions of documents with a few hundred MB of RAM.

Configuration. Getting Elasticsearch to return good search results requires tuning analyzers, tokenizers, field mappings, and query boosting. Meilisearch returns good results by default because it is opinionated about ranking.

Operations. Elasticsearch was designed for distributed clusters. Even for a single-node setup, you deal with cluster health, shard management, and index lifecycle policies. Meilisearch is a single binary with a RESTful API. Start it and it works.

Query complexity. An Elasticsearch query for a simple product search can be 30+ lines of JSON with multi_match, function_score, and filter contexts. The Meilisearch equivalent:

curl 'http://localhost:7700/indexes/products/search' \
  -d '{"q": "wireles keyboard", "limit": 10}'

Notice the typo in "wireles." Meilisearch handles it and returns wireless keyboards anyway.

Setting it up

services:
  meilisearch:
    image: getmeili/meilisearch:latest
    container_name: meilisearch
    restart: unless-stopped
    ports:
      - "7700:7700"
    volumes:
      - ./meili-data:/meili_data
    environment:
      - MEILI_MASTER_KEY=your-secret-key

That is the entire setup. One container, one port, one environment variable for the API key.

Indexing data

Push documents to an index via the API:

const response = await fetch("http://localhost:7700/indexes/posts/documents", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    Authorization: "Bearer your-secret-key",
  },
  body: JSON.stringify([
    { id: 1, title: "Getting started with Docker", category: "Tech", content: "..." },
    { id: 2, title: "Why I use Linux", category: "Tech", content: "..." },
  ]),
});

Meilisearch automatically indexes all fields and makes them searchable. You can configure which fields are searchable, filterable, and sortable, but the defaults work for most cases.

Typo tolerance and ranking

This is where Meilisearch shines. It uses a ranking system designed for human search behavior:

  1. Typo tolerance. "reciepe" matches "recipe." "javscript" matches "javascript." This works automatically with no configuration.

  2. Prefix search. Typing "doc" matches "docker" and "documentation" in real time as the user types.

  3. Ranking rules. Results are ranked by word proximity, typo count, attribute importance, and exactness. The defaults produce results that feel right for end-user search.

Filtering and faceting

Meilisearch supports filters for narrowing results:

curl 'http://localhost:7700/indexes/products/search' \
  -d '{
    "q": "keyboard",
    "filter": "category = electronics AND price < 100",
    "facets": ["category", "brand"]
  }'

The response includes facet counts so you can build filter UIs (like "Electronics (24), Accessories (8)").

When Elasticsearch is the better choice

If you need log aggregation (use the ELK stack), complex analytics queries, geospatial search at scale, or you are indexing billions of documents across a distributed cluster, Elasticsearch is the right tool.

For application search where users type queries and expect fast, relevant results, Meilisearch is simpler, faster to set up, lighter on resources, and produces better results out of the box.

What I use it for

I use Meilisearch for search functionality in web applications. It handles product catalogs, documentation search, and content indexing. The instant search experience (results appearing as you type) is something users notice and appreciate.

For my blog, I have considered adding Meilisearch-powered search but with good category filtering and year navigation, it has not been necessary yet.

Sources

Enjoying the blog? Subscribe via RSS to get new posts in your reader.

Subscribe via RSS