Refactoring Meilisearch: v0.21 has entered the chat

Today we are releasing the first release candidate (RC) of Meilisearch v0.21. This is the initial step towards the next version of Meilisearch, and a pretty important one given that it will be our first major release since March.

A big part of v0.21 will be relatively invisible to most end-users: our core team has been hard at work refactoring Meilisearch’s engine, something that is as time-consuming as it is crucial for the long-term health of our codebase. In this post, I want to go over why we decided to refactor Meilisearch, how that impacted our product, and where we’ll go from here.

We won’t be discussing everything that’s changed between v0.20 and v0.21—that’s for another blog post—but we will touch on several of the new features we are most excited about.

Why was refactoring needed?

We first realized that something was wrong when it became increasingly difficult for our core team to add new features without impacting performance. We could see our code was becoming more difficult to maintain, which is something particularly concerning for an open-source project: our community is our greatest ally and keeping code clean, readable, and pleasant-to-use is crucial if we want to keep our allies happy. We were clearly reaching the limits of what the previous codebase could offer us in terms of performance and ease-of-use, so we decided it was time for a change.

How did we do?

We have a lot of good news—but, as with any major software release, there were some goals we weren’t able to attain.

Search relevancy

The v0.21.0 will provide new ways to make your search more relevant:

  • You can now use numeric attributes as facets—think things like the price of a product or the release date of a book
  • This was actually requested by our users: the equivalent of Algolia’s words criterion is now available in Meilisearch!
  • Phrase search: users can now force the engine to only return exact matches by enclosing query terms in double quotes (")
  • Highlighting is now available for array and object values

Search performance

Searching through huge datasets with Meilisearch has never been so fast! With a 1GB dataset containing around 115 million documents:

  • Queries that return many results are more than ten times faster: searching for a single letter takes less than 50ms in v0.21, compared with 2 seconds in v0.20
  • Similar speed gains when filtering on numbers: most searches take less than 50ms in v0.21

Indexation

TLDR; indexation is now faster in most cases, but there are exceptions. Lots of room for improvement!

First, the good bits: indexation is globally faster with the refactored search engine.

Unfortunately, we noticed a loss of performance when parsing datasets with lengthy description values (think a list of blog posts or scientific articles with excerpts and abstracts) in v0.21. This is not a complete surprise: the new search engine requires more calculations, which means indexation might take more time. This is not ideal, but we would rather release something that’s not completely optimized than delay v0.21 and all the new features it will introduce. Rest assured, we are doing our best to improve indexation performance.

Another bit of bad news: while we have made significant steps in the right direction and reduced memory consumption across the board, the issue of Meilisearch sometimes crashing due to excessive memory usage has still not been fixed. This is another priority for us going forward.

Are there any breaking changes?

There are indeed! We did our best to avoid breaking changes, but that’s not always possible when we want to keep improving things and making our API easier to use. The two biggest changes related to v.021’s refactoring are:

  • The parameters filters and facetFilter have been replaced by filter. Having two parameters doing almost the same thing added unnecessary complexity when filtering query results
  • Several naming changes that we believe make using Meilisearch more intuitive. None of these have any impact on the end-user experience. A full list will be available when we officially release v0.21

What’s next?

Once v0.21 is officially released some time within the next three months, we will return to our monthly release cycle. We are particularly looking forward to working on sortBy and geographical search—two features that are highly requested by our users. We hear you loud and clear!

If you are curious about Meilisearch’s upcoming version, feel free to test it and give us as much feedback as possible—we depend on you to catch as many remaining bugs as possible. You can download the release candidate on GitHub.

Also, a word of advice: we do not recommend using this RC in production. We are confident v0.21 RC1 is looking pretty good, but there are still issues that we need to work out before it is ready for the spotlight.

Thank you again, and see you soon for the official v0.21.0 release!