Slackbot
06/04/2025, 7:52 AMFanis Tharropoulos
06/04/2025, 8:49 AM--enable-search-analytics flag and automatic aggregation are actually two separate features. The flag simply enables search analytics functionality overall, rather than handling the aggregation aspect specifically.
Regarding automatic aggregation, could you help me understand what exactly you're looking to disable? Just so you know, the aggregation only kicks in after you've set up either a no hits rule or a popular queries rule.
If you'd like to change the default behavior, you can use the enable_auto_aggregation parameter when creating your Analytics rule and
set it to false. This way, events won't automatically get sent to the server.
DocsMarri Shiva
06/05/2025, 5:38 AMuserId
• shopId
• zipcode
• query (q)
• count
• date (for date-wise analytics)
Since the default popular_queries rule only stores q and count, we plan to log and aggregate analytics ourselves, so we can support both custom metadata and date-wise reports.
To achieve this, we’d like to confirm the following:
1. If we set "enable_auto_aggregation": false while creating a popular_queries rule, will that completely disable automatic writes to the destination_collection?
2. Is there a recommended approach to implement custom search analytics with date-wise grouping, or can we rely on manually writing to a collection for this purpose?Fanis Tharropoulos
06/05/2025, 10:07 AMpopular_queries rule isMarri Shiva
06/05/2025, 10:14 AM{
"name": "qa_product_queries_aggregation",
"type": "popular_queries",
"params": {
"source": {
"collections": [
"qa-products"
]
},
"destination": {
"collection": "qa-product-queries"
},
"expand_query": false,
"enable_auto_aggregation": false,
"limit": 1000,
"events": [
{
"type": "search",
"name": "qa-products_search_event"
}
]
}
}
However, when I try to retrieve the rule using: GET /analytics/rules
it returns an empty object or list, even though the creation call was successful.
Also, when I try to send an event like this:
{
"type": "search",
"name": "qa-products_search_event",
"data": {
"q": "mango",
"user_id": "123",
"shop_id": "shop_456",
"zipcode": "560001",
"timestamp": 1717580000000
}
}
I get the error:
{"message": "No analytics rule defined for event name qa-products_search_event"}
Why the rule doesn’t show up when I retrieve it?
Why the event is not being matched, even though the name matches exactly?Fanis Tharropoulos
06/05/2025, 10:18 AMMarri Shiva
06/05/2025, 10:19 AMFanis Tharropoulos
06/05/2025, 10:20 AMMarri Shiva
06/05/2025, 10:20 AMFanis Tharropoulos
06/05/2025, 10:28 AMFanis Tharropoulos
06/05/2025, 10:29 AM{
"rules": [
{
"name": "qa_product_queries_aggregation",
"params": {
"destination": {
"collection": "qa-product-queries"
},
"expand_query": false,
"limit": 1000,
"source": {
"collections": [
"qa-products"
]
}
},
"type": "popular_queries"
}
]
}Marri Shiva
06/05/2025, 10:29 AMFanis Tharropoulos
06/05/2025, 10:31 AMcurl "https://vjzoc4yu2fq3k7rmp-1.a1.typesense.net/analytics/events" -X POST \
-H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
-d '{
"type": "search",
"name": "qa-products_search_event",
"data": {
"q": "dummy search",
"user_id": "1234"
}
}
Could you try this now? It should work.Marri Shiva
06/05/2025, 10:34 AMFanis Tharropoulos
06/05/2025, 10:35 AM{
"name": "product_queries_aggregation",
"type": "popular_queries",
"params": {
"source": {
"collections": [
"qa-products"
],
"enable_auto_aggregation": false,
"events": [
{
"type": "search",
"name": "qa-products_search_event"
}
]
},
"destination": {
"collection": "qa-product_queries"
},
"limit": 1000
}
}Fanis Tharropoulos
06/05/2025, 10:36 AMenable_auto_aggregation to false and define a search event as wellMarri Shiva
06/05/2025, 10:45 AMFanis Tharropoulos
06/05/2025, 10:45 AMMarri Shiva
06/05/2025, 11:56 AMMarri Shiva
06/05/2025, 11:57 AMFanis Tharropoulos
06/05/2025, 11:58 AMqa-product-queries exist and is the same as the one you posted?Marri Shiva
06/05/2025, 11:59 AMMarri Shiva
06/05/2025, 12:00 PMMarri Shiva
06/05/2025, 12:02 PMFanis Tharropoulos
06/05/2025, 12:07 PM❮ curl -k "https://vjzoc4yu2fq3k7rmp-1.a1.typesense.net/analytics/rules" \
-X POST \
-H "Content-Type: application/json" \
-H "X-TYPESENSE-API-KEY: redacted" \
-d '{
"name": "product_queries_aggregation",
"type": "popular_queries",
"params": {
"source": {
"collections": [
"qa-products-1745829004935"
],
"enable_auto_aggregation": false,
"events": [
{
"type": "search",
"name": "qa-products_search_event"
}
]
},
"destination": {
"collection": "qa-product-queries" <- Hyphen instead of underscore
},
"limit": 1000
}
}
'
{"name":"product_queries_aggregation","params":{"destination":{"collection":"qa-product-queries"},"limit":1000,"source":{"collections":["qa-products-1745829004935"],"enable_auto_aggregation":false,"events":[{"name":"qa-products_search_event","type":"search"}]}},"type":"popular_queries"}%
❯ curl "https://vjzoc4yu2fq3k7rmp-1.a1.typesense.net/analytics/events" -X POST \
-H "X-TYPESENSE-API-KEY: redacted" \
-d '{
"type": "search",
"name": "qa-products_search_event",
"data": {
"q": "dummy search",
"user_id": "1234"
}
}'
{"ok": true}%Marri Shiva
06/06/2025, 4:44 AMq, count, and user_id. In the POST call, you are passing both q and user_id. The q value is being saved in the destination collection, and the count is being populated automatically. However, the user_id is not being saved in the destination collection. Why is that?Fanis Tharropoulos
06/06/2025, 4:23 PMuser_id isn't evaluated for popularity rules, and won't be saved, regardless if you have it defined in the schema or notMarri Shiva
06/09/2025, 6:14 AMuser_id is not used or stored when using popular_queries rules. However, the API returns an error if I omit user_id from the analytics event payload:
`{"message": "search event json data fields should contain user_id as string value."}`
If user_id is not stored or evaluated, could you please clarify what its purpose is in the context of analytics events? Why is it required in the payload?Fanis Tharropoulos
06/10/2025, 9:58 AMuser_id, only converion and clicks should require it. Is this throwing for a search event type?Marri Shiva
06/10/2025, 12:37 PMFanis Tharropoulos
06/11/2025, 4:59 AMMarri Shiva
06/12/2025, 6:42 AM