This article will walk you through the steps required to add custom ranking attributes to your application using an API client.
1. First, specify the custom ranking attributes using the setSettings method. For example,
index.setSettings({
customRanking:[
'desc(popularity)',
'asc(price)'
]
}).then(()=>{
// done
});
You can see code examples here.
2. Then, pass the custom criterion at the bottom of the ranking array.
ranking: [ // the `asc` and `desc` modifiers must be placed at the top // if you are configuring an index for sorting purposes only 'asc(attribute1)', 'desc(attribute2)', 'typo', 'geo', 'words', 'filters', 'proximity', 'attribute', 'exact', 'custom' ]