Skip to main content
Relevancy refers to the accuracy and effectiveness of search results. If search results are almost always appropriate, then they can be considered relevant, and vice versa. Meilisearch has a number of features for fine-tuning the relevancy of search results. The most important tool among them is ranking rules. There are two types of ranking rules: built-in ranking rules and custom ranking rules.

Behavior

Each index possesses a list of ranking rules stored as an array in the settings object. This array is fully customizable, meaning you can delete existing rules, add new ones, and reorder them as needed. Meilisearch uses a bucket sort algorithm to rank documents whenever a search query is made. The first ranking rule applies to all documents, while each subsequent rule is only applied to documents considered equal under the previous rule as a tiebreaker. The order in which ranking rules are applied matters. The first rule in the array has the most impact, and the last rule has the least. Our default configuration meets most standard needs, but you can change it. Deleting a rule means that Meilisearch will no longer sort results based on that rule. For example, if you delete the typo ranking rule, documents with typos will still be considered during search, but they will no longer be sorted by increasing number of typos.

How ranking works

Meilisearch uses a bucket sort pipeline to determine which documents best match a query. The engine applies ranking rules sequentially: the first rule sorts all matching documents into broad groups (or “buckets”), and each subsequent rule acts as a tiebreaker within those groups. Because earlier rules have the greatest impact on final ordering, the position of each rule in the array matters significantly. By default, Meilisearch ships with built-in ranking rules that handle word matching, typo tolerance, proximity, attribute weight, exactness, and more. You can also insert custom ranking rules at any position in the pipeline to sort by numeric or date fields specific to your dataset (for example, sorting by a popularity score or a release date).

Chunking large documents

Meilisearch is optimized for paragraph-sized chunks of text. Documents with very large text fields (multiple pages of content) may lead to reduced search relevancy because ranking rules like proximity and word position work best on shorter text. If your dataset contains large documents, split them into smaller chunks (one per paragraph or section) before indexing. Each chunk becomes its own document with a shared identifier linking it back to the original. Use Meilisearch’s distinct attribute to prevent duplicates in search results. For example, a book with 50 paragraphs becomes 50 documents, each containing one paragraph plus the book’s metadata (title, author). The distinct attribute ensures only the best-matching paragraph is returned per book.

Explore relevancy features

Ranking rules

Understand the built-in ranking rules and how they determine result order

Custom ranking rules

Add your own ranking rules based on numeric or date attributes

Ranking score

Inspect the relevancy score assigned to each search result

Attribute ranking order

Control which document attributes carry the most weight in ranking

Typo tolerance

Configure how Meilisearch handles spelling mistakes

Synonyms

Define equivalent terms so users find results regardless of wording