You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: assets/open-api/meilisearch-openapi-mintlify.json
+12-4Lines changed: 12 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -17534,10 +17534,18 @@
17534
17534
},
17535
17535
{
17536
17536
"type": "string",
17537
-
"description": "Documents with quey words contained in more important\nattributes are considered better.",
17538
-
"enum": [
17539
-
"Attribute"
17540
-
]
17537
+
"description": "Documents with query words contained in more important\nattributes are considered better.",
17538
+
"enum": ["AttributeRank"]
17539
+
},
17540
+
{
17541
+
"type": "string",
17542
+
"description": "Documents with query words at the beginning of an attribute\nare considered better.",
17543
+
"enum": ["WordPosition"]
17544
+
},
17545
+
{
17546
+
"type": "string",
17547
+
"description": "Legacy rule combining AttributeRank and WordPosition.\nDocuments with query words contained in more important\nattributes are considered better.",
Copy file name to clipboardExpand all lines: guides/relevancy/ordering_ranking_rules.mdx
+8-6Lines changed: 8 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,12 +37,13 @@ This covers things like:
37
37
38
38
**These three rules cast a wide net and return lots of results.** That's good—you want to start broad and then narrow down, not the other way around. If you start too narrow you can lose relevancy easily.
**Group 2 - Fine-tuning : Exactness, Attribute Rank, Word Position (included in ranking score)**
41
41
42
42
This covers things like:
43
43
44
44
-**Exactness**: Did the document match your whole search term or just pieces of it? Whole matches rank higher, especially when an entire field matches exactly or starts with your query. Documents containing extra content beyond the search term are ranked lower.
45
-
-**Attribute**: Matches in your most important fields rank higher, and matches near the beginning of a field rank higher. You set field priority in `searchableAttributes`, with fields at the top of the list treated as the most important.
45
+
-**Attribute Rank**: Matches in your most important fields rank higher. You set field priority in `searchableAttributes`, with fields at the top of the list treated as the most important.
46
+
-**Word Position**: Matches near the beginning of a field rank higher.
46
47
47
48
**These are your fine-tuning filters.** They return fewer, more precise results. Use these after Group 1 rules to refine your large result set into something more precise.
48
49
@@ -75,8 +76,9 @@ Ranking rules:
75
76
"words",
76
77
"typo",
77
78
"proximity",
78
-
"attribute",
79
+
"attributeRank",
79
80
"sort", // "price:asc" "author:desc" gets swapped in here
81
+
"wordPosition",
80
82
"exactness",
81
83
"release_date:asc",
82
84
"movie_ranking:desc"
@@ -99,7 +101,7 @@ These three rules cast a wide net and pass a large pool of relevant results thro
99
101
100
102
### Place Sort strategically
101
103
102
-
We recommend putting Sort after your Group 1 rules and before your Group 2 rules (Attribute, Exactness). This way, Meilisearch finds relevant results first and then uses your sort field to order documents that have similar text relevance, giving you a balance of match quality and sorting.
104
+
We recommend putting Sort after your Group 1 rules and before your Group 2 rules (Attribute Rank, Word Position, Exactness). This way, Meilisearch finds relevant results first and then uses your sort field to order documents that have similar text relevance, giving you a balance of match quality and sorting.
103
105
104
106
If sorting matters more than text relevance for your use case - like an e-commerce price filter where users expect strict price ordering - move Sort higher. Just remember that Sort only activates when you include the `sort` parameter in your search query. Without it, the Sort rule has no effect.
105
107
@@ -114,9 +116,9 @@ Place custom ranking rules at the end of your sequence. They work best for addin
114
116
Each ranking rule has its own settings you can fine-tune beyond just ordering. For example, you can adjust which fields take priority in attribute ranking, or configure how aggressively typo tolerance matches similar words. If you want to dig into the specifics:
115
117
116
118
-[Built-in ranking rules](https://www.meilisearch.com/docs/learn/relevancy/ranking_rules#list-of-built-in-ranking-rules) — how each rule works and what it evaluates
117
-
-[Attribute ranking order](https://www.meilisearch.com/docs/learn/relevancy/attribute_ranking_order) — controlling which fields matter most
119
+
-[Attribute ranking order](https://www.meilisearch.com/docs/learn/relevancy/attribute_ranking_order) — controlling which fields matter most with `attributeRank` and `wordPosition`
118
120
-[Typo tolerance settings](https://www.meilisearch.com/docs/learn/relevancy/typo_tolerance_settings) — adjusting how flexible matching behaves
119
121
120
122
**Want to see these rules in action?** In our next guide, [How Do I Interpret Ranking Score Details?](/guides/relevancy/interpreting_ranking_scores), we walk through a real example showing exactly how Meilisearch evaluates each rule — and how moving Sort one position can flip your results.
Copy file name to clipboardExpand all lines: learn/relevancy/attribute_ranking_order.mdx
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,5 +38,7 @@ By default, nested fields share the same weight as their parent attribute. Use d
38
38
With the above ranking order, `review.critic` becomes more important than its sibling `review.user` when calculating a document's ranking score.
39
39
40
40
<Note>
41
-
The `attribute` rule's position in [`rankingRules`](/learn/relevancy/ranking_rules) determines how the results are sorted. Meaning, **if `attribute` is at the bottom of the ranking rules list, it will have almost no impact on your search results.**
41
+
The `attributeRank` and `wordPosition` rules' positions in [`rankingRules`](/learn/relevancy/ranking_rules) determine how the results are sorted. Meaning, **if `attributeRank` is at the bottom of the ranking rules list, it will have almost no impact on your search results.**
42
+
43
+
The legacy `attribute` rule combines both `attributeRank` and `wordPosition`. If you use `attribute`, its position determines the impact of both attribute ranking order and position within attributes.
Copy file name to clipboardExpand all lines: learn/relevancy/ranking_rules.mdx
+27-10Lines changed: 27 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,15 +10,16 @@ Built-in ranking rules are the core of Meilisearch's relevancy calculations.
10
10
11
11
## List of built-in ranking rules
12
12
13
-
Meilisearch contains six built-in ranking rules in the following order:
13
+
Meilisearch contains seven built-in ranking rules in the following order:
14
14
15
15
```json
16
16
[
17
17
"words",
18
18
"typo",
19
19
"proximity",
20
-
"attribute",
20
+
"attributeRank",
21
21
"sort",
22
+
"wordPosition",
22
23
"exactness"
23
24
]
24
25
```
@@ -47,21 +48,37 @@ Results are sorted by **increasing distance between matched query terms**. Retur
47
48
48
49
[It is possible to lower the precision of this ranking rule.](/reference/api/settings#proximity-precision) This may significantly improve indexing performance. In a minority of use cases, lowering precision may also lead to lower search relevancy for queries using multiple search terms.
49
50
50
-
## 4. Attribute
51
+
## 4. Attribute rank
51
52
52
53
Results are sorted according to the **[attribute ranking order](/learn/relevancy/attribute_ranking_order)**. Returns documents that contain query terms in more important attributes first.
53
54
54
-
Also, note the documents with attributes containing the query words at the beginning of the attribute will be considered more relevant than documents containing the query words at the end of the attributes.
55
+
This rule evaluates only the attribute ranking order and does not consider the position of matched words within attributes.
55
56
56
-
## 5. Sort
57
+
## 5. Attribute position
58
+
59
+
Results are sorted by the **position of query terms within the attributes**. Returns documents that contain query terms closer to the beginning of an attribute first.
60
+
61
+
This rule evaluates only the position of matched words within attributes and does not consider the attribute ranking order.
62
+
63
+
## Attribute
64
+
65
+
`attribute` is an older built-in ranking rule equivalent to using both `attributeRank` and `wordPosition` together. When you use `attribute`, Meilisearch first sorts results by the attribute ranking order, then uses the position within attributes as a tiebreaker.
66
+
67
+
<Warning>
68
+
You cannot use `attribute` together with `attributeRank` or `wordPosition`. If you try to configure ranking rules with both, Meilisearch will return an error. We recommend using a combination of the `attributeRank` and `wordPosition` rules.
69
+
</Warning>
70
+
71
+
For most use-cases, we recommend using `attributeRank` and `wordPosition` separately. This gives you more control over result ordering by allowing you to place other ranking rules (like `sort` or custom ranking rules) between them.
72
+
73
+
## 6. Sort
57
74
58
75
Results are sorted **according to parameters decided at query time**. When the `sort` ranking rule is in a higher position, sorting is exhaustive: results will be less relevant but follow the user-defined sorting order more closely. When `sort` is in a lower position, sorting is relevant: results will be very relevant but might not always follow the order defined by the user.
59
76
60
77
<Note>
61
78
Differently from other ranking rules, sort is only active for queries containing the [`sort` search parameter](/reference/api/search#sort). If a search request does not contain `sort`, or if its value is invalid, this rule will be ignored.
62
79
</Note>
63
80
64
-
## 6. Exactness
81
+
## 7. Exactness
65
82
66
83
Results are sorted by **the similarity of the matched words with the query words**. Returns documents that contain exactly the same terms as the ones queried first.
67
84
@@ -95,16 +112,16 @@ The reason why `Creature` is listed before `Mississippi Grind` is because of the
95
112
The `proximity` rule sorts the results by increasing distance between matched query terms.
96
113
</Tab>
97
114
98
-
<Tabtitle="Attribute">
115
+
<Tabtitle="Attribute rank">
99
116
<Frame>
100
-
<imgsrc="/assets/images/ranking-rules/belgium.png"alt="Demonstrating the attribute ranking rule by searching for 'belgium'" />
117
+
<imgsrc="/assets/images/ranking-rules/belgium.png"alt="Demonstrating the attributeRank ranking rule by searching for 'belgium'" />
101
118
</Frame>
102
119
103
-
### Attribute
120
+
### Attribute rank
104
121
105
122
`If It's Tuesday, This must be Belgium` is the first document because the matched word `Belgium` is found in the `title` attribute and not the `overview`.
106
123
107
-
The `attribute` rule sorts the results by [attribute importance](/learn/relevancy/attribute_ranking_order).
124
+
The `attributeRank` rule sorts the results by [attribute importance](/learn/relevancy/attribute_ranking_order).
Copy file name to clipboardExpand all lines: learn/relevancy/ranking_score.mdx
+9-8Lines changed: 9 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ description: This article explains how the order of attributes in the `searchabl
6
6
7
7
When using the [`showRankingScore` search parameter](/reference/api/search#ranking-score), Meilisearch adds a global ranking score field, `_rankingScore`, to each document. The `_rankingScore` is between `0.0` and `1.0`. The higher the ranking score, the more relevant the document.
8
8
9
-
Ranking rules sort documents either by relevancy (`words`, `typo`, `proximity`, `exactness`, `attribute`) or by the value of a field (`sort`). Since `sort` doesn't rank documents by relevancy, it does not influence the`_rankingScore`.
9
+
Ranking rules sort documents either by relevancy (`words`, `typo`, `proximity`, `exactness`, `attributeRank`, `wordPosition`) or by the value of a field (`sort`). Since `sort` doesn't rank documents by relevancy, it does not influence the`_rankingScore`.
10
10
11
11
<Note>
12
12
A document's ranking score does not change based on the scores of other documents in the same index.
@@ -16,10 +16,11 @@ For example, if a document A has a score of `0.5` for a query term, this value r
16
16
17
17
The table below details all the index settings that can influence the `_rankingScore`. **Unlisted settings do not influence the ranking score.**
|`searchableAttributes`| The `attribute` ranking rule is used | The `attribute` ranking rule rates the document depending on the attribute in which the query terms show up. The order is determined by `searchableAttributes`|
22
-
|`rankingRules`| Always | The score is computed by computing the subscore of each ranking rule with a weight that depends on their order |
23
-
|`stopWords`| Always | Stop words influence the `words` ranking rule, which is almost always used |
24
-
|`synonyms`| Always | Synonyms influence the `words` ranking rule, which is almost always used |
25
-
|`typoTolerance`| The `typo` ranking rule is used | Used to compute the maximum number of typos for a query |
|`searchableAttributes`| The `attributeRank` ranking rule is used | The `attributeRank` ranking rule rates the document depending on the attribute in which the query terms show up. The order is determined by `searchableAttributes`|
22
+
|`searchableAttributes`| The `wordPosition` ranking rule is used | The `wordPosition` ranking rule rates the document based on the position of query terms within attributes |
23
+
|`rankingRules`| Always | The score is computed by computing the subscore of each ranking rule with a weight that depends on their order |
24
+
|`stopWords`| Always | Stop words influence the `words` ranking rule, which is almost always used |
25
+
|`synonyms`| Always | Synonyms influence the `words` ranking rule, which is almost always used |
26
+
|`typoTolerance`| The `typo` ranking rule is used | Used to compute the maximum number of typos for a query |
0 commit comments