We are currently implementing analytics events in ...
# community-help
a
We are currently implementing analytics events in Typesense for click, add_to_cart, and purchase, each with a base weight of 1. Now, we want to introduce a
ranking_score
field that should be automatically calculated using the following formula:
Copy code
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:
Copy code
sort_by: ranking_score:desc
Would appreciate your guidance on the best approach for this. as provided solution "message": "Rule event type cannot be changed" getting error for custom_event creation payload is { "name": "book_click_custom", "type": "counter", "collection": "books_collection", "event_type": "custom", "params": { "destination_collection": "books_collection", "counter_field": "ranking", "weight": 1 } }
f
Duplicate thread, let's keep the conversation under https://typesense-community.slack.com/archives/C01P749MET0/p1773822625534209