Skip to content

Commit 7a59d17

Browse files
shorten custom ranking rules page, add tip for searchable attribs
1 parent 4375cf3 commit 7a59d17

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

learn/relevancy/custom_ranking_rules.mdx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,26 @@ sidebarTitle: Custom ranking rules
44
description: Custom ranking rules promote certain documents over other search results that are otherwise equally relevant.
55
---
66

7-
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.
7+
There are two types of ranking rules in Meilisearch: [built-in ranking rules](/learn/relevancy/ranking_rules) and custom ranking rules.
88

99
Custom ranking rules promote certain documents over other search results that are otherwise equally relevant.
1010

11+
1112
## Ascending and descending sorting rules
1213

13-
Meilisearch supports two types of custom rules: one for ascending sort and one for descending sort.
14+
Meilisearch supports two types of custom rules: ascending and descending sorting. **The attribute must have either a numeric or a string value** in all of the documents contained in that index. Sorting is done lexicographically.
1415

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.
16+
Add custom ranking rules 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). Specify the attribute name followed by a colon (`:`) and either `asc` for ascending order or `desc` for descending order:
1617

17-
- To apply an **ascending sort** (results sorted by increasing value of the attribute): `attribute_name:asc`
18+
- Sort results with lowest value on top: `attribute_name:asc`
1819

19-
- To apply a **descending sort** (results sorted by decreasing value of the attribute): `attribute_name:desc`
20+
- Sort results with highest value on top: `attribute_name:desc`
2021

21-
**The attribute must have either a numeric or a string value** in all of the documents contained in that index.
22+
<Tip>
23+
Custom ranking rules are simple lexicographical sorts and do not order results based on relevancy. In most cases, custom ranking rules should be at the bottom of your ranking rules list.
2224

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).
25+
To ensure Meilisearch gives more weight to a specific attribute when calculating relevancy, edit the order of [the searchable attributes list](/reference/api/settings#searchable-attributes).
26+
</Tip>
2427

2528
## Example
2629

@@ -57,9 +60,9 @@ The following array includes all built-in ranking rules and places the custom ru
5760

5861
Meilisearch allows users to define [sorting order at query time](/learn/filtering_and_sorting/sort_search_results) by using the [`sort` search parameter](/reference/api/search#sort). There is some overlap between sorting and custom ranking rules, but the two do have different uses.
5962

60-
In general, `sort` will be most useful when you want to allow users to define what type of results they want to see first. A good use-case for `sort` is creating a webshop interface where customers can sort products by descending or ascending product price.
63+
Custom ranking rules are always active once configured. They are useful when you want to promote certain types of results across all searches. A good use-case for custom ranking rules is ensuring discounted products in a webshop always feature among the top results.
6164

62-
Custom ranking rules, instead, are always active once configured and are useful when you want to promote certain types of results. A good use-case for custom ranking rules is ensuring discounted products in a webshop always feature among the top results.
65+
The `sort` search parameter is useful when you want to allow users to define what type of results they want to see first. A good use-case for `sort` is creating a webshop interface where customers can sort products by descending or ascending product price.
6366

6467
<Tip>
6568
Meilisearch does not offer native support for promoting, pinning, and boosting specific documents so they are displayed more prominently than other search results. Consult these Meilisearch blog articles for workarounds on [implementing promoted search results with React InstantSearch](https://blog.meilisearch.com/promoted-search-results-with-react-instantsearch) and [document boosting](https://blog.meilisearch.com/document-boosting).

0 commit comments

Comments
 (0)