Akash Kumar
03/18/2026, 8:30 AMranking_score field that should be automatically calculated using the following formula:
ranking_score = click + (add_to_cart * 2) + (purchase * 5)
What we need help with:
How can we automatically update this ranking_score field whenever new events are recorded?
• Is there a way to compute this dynamically within Typesense (e.g., via analytics rules or derived fields)?
• Or should this be handled externally (e.g., via backend cron/job or event pipeline)?
Goal:
We want ranking_score to always stay up-to-date and be used in:
sort_by: ranking_score:desc
Would appreciate your guidance on the best approach for this.
@Kishore NallanFanis Tharropoulos
03/18/2026, 8:48 AM{
"name": "product_click",
"type": "counter",
"collection": "products",
"event_type": "click",
"params": {
"counter_field": "ranking_score",
"weight": 1
}
}
{
"name": "product_add_to_cart",
"type": "counter",
"collection": "products",
"event_type": "custom",
"params": {
"counter_field": "ranking_score",
"weight": 2
}
}
{
"name": "product_purchase",
"type": "counter",
"collection": "products",
"event_type": "custom",
"params": {
"counter_field": "ranking_score",
"weight": 5
}
}
So in practice, yes, ranking_score becomes click + add_to_cart 2 + purchase 5 without needing an external job.
The main caveat is that custom event names like add_to_cart and purchase would need to be sent as custom events. Also, updates are asynchronous, so the score is automatically maintained but not strictly instant per event. It relies on the analytics-flush-interval server parameterAkash Kumar
03/18/2026, 9:14 AMAkash Kumar
03/18/2026, 9:46 AMFanis Tharropoulos
03/18/2026, 9:58 AMAkash Kumar
03/18/2026, 10:51 AMFanis Tharropoulos
03/18/2026, 11:28 AMAkash Kumar
03/18/2026, 11:33 AMAkash Kumar
03/18/2026, 11:36 AMFanis Tharropoulos
03/18/2026, 11:52 AMAkash Kumar
03/18/2026, 12:23 PMFanis Tharropoulos
03/18/2026, 12:59 PMAkash Kumar
03/18/2026, 1:02 PM