ranking and sales_score are added in analytics rul...
# community-help
a
ranking and sales_score are added in analytics rule but we want for 1 time we update sale_score and ranking based on our data in bulk @Kishore Nallan but as normal data is update by upsert method these feild is not update
f
ranking / sales_score added through analytics rules won’t behave like protected fields. Analytics counter updates happen through the analytics flush flow, which uses partial update with increment ops. But your normal product sync is using upsert, and if those fields are not included in the upsert payload, they can get overwritten / dropped. So if you want to set sales_score and ranking once in bulk from your own data, that part is fine. But after that, regular upserts also need to send those fields if you want to preserve them. Otherwise the analytics-updated values won’t stay in sync. If that matches your case, the issue is not that analytics rule creation failed, it’s that later upsert writes are replacing documents without those fields.
a
I want to perform a one-time update of the
ranking
field using
sold_qty
(e.g.,
ranking = sold_qty * 5
). After this initial setup, the ranking should be adjusted dynamically based on analytics events such as clicks, cart additions, and purchases.
f
That should work, but only if your normal document upserts keep the ranking field. The one-time bulk update can set
ranking = sold_qty * 5
as the base value. After that, analytics events can increment the same field. The problem is that if your regular sync later uses upsert without sending ranking, that base + analytics value can be overwritten or removed. So the flow would be: 1. First, run a one-time bulk update to set the initial ranking. 2. Configure analytics rules to increment ranking for clicks / cart / purchase events. 3. Make sure future upserts also include ranking, or avoid overwriting that field in the regular sync. Otherwise the analytics adjustments will not persist correctly.
a
just clear once if for current remove analtics rule for ranking and then update using bulk upsert once updated , again set analtics rule for ranking and update ranking by event is it ok?
f
You can remove the analytics rule for ranking, run the one-time bulk update to set the initial values, then create the analytics rule again so future events increment ranking. The main thing to watch is what happens after that. If your normal document upserts do not include ranking, they can still overwrite/remove the field later. So re-enabling the analytics rule is fine, but your regular sync must also preserve ranking going forward.