Hi everyone, Is it possible to have multiple anal...
# community-help
m
Hi everyone, Is it possible to have multiple analytics rules for the same collection? I'm trying to configure a rule to update three different fields: number of visits, clicks, and downloads. However, after creating the first rule, I get the following error:
There's already another configuration for this destination collection.
Any insights on how to work around this?
j
CC: @Krunal Gandhi
k
Hi @Marcos Passos Typesense doesn't allow multiple analytics rules per collection. It supports multiple counter events which you can pass in events array in analytics rule. For your use case, you might need to make 3 different collection and create counter rule for each of them.
Could you please open a feature request for same. We're thinking to support it via specifying counter_field to increment per event like below,
Copy code
{
    "name": "product_popularity",
    "type": "counter",
    "params": {
        "source": {
            "collections": ["products"],
            "events":  [
                {"type": "click", "weight": 1, "name": "CLK1",  "counter_field": <field1>},
                {"type": "visits", "weight": 1, "name": "VST1",  "counter_field": <field2>},
                {"type": "downloads", "weight": 1, "name": "DLD1",  "counter_field": <field3>}
            ]
        },
        "destination": {
            "collection": "products"
        }
    }
}
If you've better suggestion then let us know. we will see at our end if it can be possible.
m
The problem is that having multiple collections does not solve the problem. The reason why I need this is to have different sorting options, like sorting by the number of downloads, popularity, etc.
Your suggestion LGTM