Using Algolia Custom Ranking to Boost Business Metrics Without Losing Relevance
Learn how Algolia’s Custom Ranking lets business metrics like rating or stock act as tie‑breakers after textual relevance, with a concrete e‑commerce example, configuration steps, and verification tips.
05 Jul 2026, 23:33 UTC

Problem: Pure textual relevance can hide profitable items
When Algolia ranks records, the default formula looks only at how well the query matches the text in each record. If two products have the same textual score, their order is arbitrary. This means a high‑margin, best‑selling item can appear below a low‑stock, low‑rated counterpart simply because the words match equally well.
Thesis: Custom Ranking lets business metrics act as tie‑breakers
Algolia’s customRanking setting adds one or more attributes (e.g., rating, stock) that are evaluated after the textual relevance score. When the textual scores are identical, the custom attributes decide the order, letting you promote items that are more popular, profitable, or available without overriding keyword relevance.
How Custom Ranking works
Algolia computes a relevance score for each record based on the query. Records are first sorted by that score. If two or more records share the exact same score, Algolia evaluates the customRanking list in order:
- Each entry is a string like
"desc(rating)"(descending) or"asc(price)"(ascending). - The first attribute that differs between the records determines the final order.
- If all custom attributes are equal, the original tie‑breaker (objectID) is used.
Because custom ranking is only a tie‑breaker, a record with a higher textual relevance will always outrank a record with a lower score, regardless of its business metrics.
Configuring Custom Ranking
Via the Dashboard
- Open the Algolia Dashboard and select your index.
- Navigate to Ranking and Sorting → Custom Ranking.
- Click Add an attribute, type the attribute name, choose Descending or Ascending, and save.
- The UI instantly shows the updated list, e.g.,
["desc(rating)", "desc(stock)"].
Via the API (requires an Admin API key)
# Replace placeholders with your values
INDEX_NAME=""
ADMIN_KEY=""
# Get current settings
curl -s -X GET \
"https://-dsn.algolia.net/1/indexes/${INDEX_NAME}/settings" \
-H "X-Algolia-API-Key: ${ADMIN_KEY}" \
-H "X-Algolia-Application-ID: "
# Update custom ranking
curl -s -X PUT \
"https://-dsn.algolia.net/1/indexes/${INDEX_NAME}/settings" \
-H "X-Algolia-API-Key: ${ADMIN_KEY}" \
-H "X-Algolia-Application-ID: " \
-H "Content-Type: application/json" \
-d '{"customRanking":["desc(rating)","desc(stock)"]}'
After a PUT request, Algolia applies the new setting immediately; however, if you change which attributes are used, you must re‑index the records so the new attribute values are searchable. Frequent changes can increase indexing latency and cost.
Worked example: e‑commerce index
Suppose an index contains two records:
- Record A:
{ "name": "Wireless Headphones", "rating": 4.8, "stock": 120 } - Record B:
{ "name": "Wireless Headphones", "rating": 4.2, "stock": 30 }
A user searches for "wireless headphones". Both records receive the same textual relevance score because the query matches the name exactly. With customRanking = ["desc(rating)", "desc(stock)"]:
- Algolia compares the
ratingvalues: 4.8 > 4.2, so Record A wins. - If the ratings were equal, it would fall back to
stock(higher stock first).
Thus the higher‑rated, higher‑stock item appears first, increasing the chance of a sale while still honoring the keyword match.
Trade‑off and limitation
Over‑emphasizing custom ranking can hurt relevance for long‑tail or niche queries where textual differences are subtle. If the custom attributes dominate the tie‑breaker, a less‑relevant item may appear before a better‑matching one simply because it scores higher on the business metric.
To mitigate this:
- Monitor click‑through rate (CTR) and conversion rate after each change.
- Adjust the order or drop attributes if you see a decline in relevance‑driven metrics.
- Consider using rankingFormula (if available) to weight textual score versus custom attributes, rather than relying solely on tie‑breaking.
Practical verification steps
- Create two test records with identical searchable fields but different values for your custom attribute (e.g.,
rating). - Run a search query that matches both records exactly (e.g., the product name).
- Check the returned order: the record with the higher custom‑ranked attribute should appear first.
- In the Dashboard, verify the setting under Ranking and Sorting → Custom Ranking.
- Via API, call
getSettingsand confirm thecustomRankingarray matches your configuration.
If the order is not as expected, re‑index the records to ensure the custom attribute values are searchable, then repeat the test.
Actionable closing
Start small: add one business metric as a descending custom ranking, run the verification test above, and watch your core search metrics. If CTR or conversion improves, consider adding a second metric; if relevance suffers, revert the change (update customRanking and re‑index). By treating custom ranking as a controlled experiment, you can let profitability guide the results without sacrificing the core promise of Algolia’s relevance engine.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.