Skip to content

Commit 950c02f

Browse files
clarify custom ranking rules usage
1 parent 33ef2db commit 950c02f

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

learn/relevancy/custom_ranking_rules.mdx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
---
22
title: Custom ranking rules
3-
sidebarTitle: Custom ranking rules
4-
description: Custom ranking rules promote certain documents over other search results that are otherwise equally relevant.
3+
description: Custom ranking rules sort results based on the lexicographical order of a specified attribute.
54
---
65

76
There are two types of ranking rules in Meilisearch: [built-in ranking rules](/learn/relevancy/ranking_rules) and custom ranking rules. This article describes the main aspects of using and configuring custom ranking rules.
87

9-
Custom ranking rules promote certain documents over other search results that are otherwise equally relevant.
8+
Custom ranking rules are lexicographical sorts. They order results based on the value of a specific attribute's alphabetic and numeric value.
109

11-
## Ascending and descending sorting rules
10+
Custom ranking rules do not take search query relevancy into consideration. In the majority of cases you should place a custom ranking after the built-in ranking rules.
1211

13-
Meilisearch supports two types of custom rules: one for ascending sort and one for descending sort.
12+
- `attribute_name:asc` sorts results by increasing attribute value. For example, `price:asc` shows a product with `price: 1.00` before a product with `price: 2.00`
1413

15-
To add a custom ranking rule, you have to communicate the attribute name followed by a colon (`:`) and either `asc` for ascending order or `desc` for descending order.
14+
- `attribute_name:desc` sorts results by decreasing attribute value. For example, `price:desc` shows a product with `price: 5.00` before a product with `price: 3.00`
1615

17-
- To apply an **ascending sort** (results sorted by increasing value of the attribute): `attribute_name:asc`
16+
**The attribute must have either a numeric or a string value** in all documents contained in that index.
1817

19-
- To apply a **descending sort** (results sorted by decreasing value of the attribute): `attribute_name:desc`
18+
You can add this rule to the existing list of ranking rules using the [update settings endpoint](/reference/api/settings#update-settings) or [update ranking rules endpoint](/reference/api/settings#update-ranking-rules).
2019

21-
**The attribute must have either a numeric or a string value** in all of the documents contained in that index.
20+
<Warning>
21+
Custom ranking rules are simple lexicographical sorts. They sort results by ascending or descending order and ignore search result relevancy.
2222

23-
You can add this rule to the existing list of ranking rules using the [update settings endpoint](/reference/api/settings#update-settings) or [update ranking rules endpoint](/reference/api/settings#update-ranking-rules).
23+
If you want to promote results with matches in certain attributes, add them at the beginning of the [searchable attributes list](/reference/api/settings#searchable-attributes).
24+
</Warning>
2425

2526
## Example
2627

0 commit comments

Comments
 (0)