Jaeyson
12/14/2024, 1:58 PM{"ok": true
Here’s the exact steps I did in cli:
curl -k "<http://localhost:8108/collections>" \
-X POST \
-H "Content-Type: application/json" \
-H "X-TYPESENSE-API-KEY: xyz" \
-d '{
"name": "products",
"fields": [
{"name": "title", "type": "string"},
{"name": "popularity", "type": "int32", "optional": true}
]
}'
curl -k "<http://localhost:8108/analytics/rules>" \
-X POST \
-H "Content-Type: application/json" \
-H "X-TYPESENSE-API-KEY: xyz" \
-d '{
"name": "products_popularity",
"type": "counter",
"params": {
"source": {
"collections": ["products"],
"events": [
{"type": "click", "weight": 1, "name": "products_click_event"}
]
},
"destination": {
"collection": "products",
"counter_field": "popularity"
}
}
}'
curl -k "<http://localhost:8108/analytics/events>" \
-X POST \
-H "Content-Type: application/json" \
-H "X-TYPESENSE-API-KEY: xyz" \
-d '{
"type": "click",
"name": "products_click_event",
"data": {
"q": "nike shoes",
"doc_id": "1024",
"user_id": "111112"
}
}'