Aloha!又是我少女人妻 Uerica!鐵人賽終於快結束拉,沒想到默默的堅持到快要終點了,我家狗狗最近訓練一身絕技,以前都站起來拍我肩膀或手臂,現在都直接拍掉我滑鼠哈哈哈
用來分析查詢行為與點擊次數有關的 API
Queries : 一個時間範圍內的被查詢和點擊次數。
Clicks : 字詞的點擊次數。
Counts : 一天的查詢與點擊總數。
依降幕返回一定時間內的查詢和點擊次數
GET /api/as/v1/engines/{ENGINE_NAME}/analytics/queries
POST /api/as/v1/engines/{ENGINE_NAME}/analytics/queries
Top Queries
利用 GET 獲取過去七天前十名的熱門查詢與次數, body 不帶任何參數
curl -X GET '{API_Endpoint}/api/as/v1/engines/{ENGINE_NAME}/analytics/queries' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer private-xxxxxxxxxx' \
-d ''
Pagination
指定回傳資料的結果筆數
指定回傳 20 筆
curl -X GET '{API_Endpoint}/api/as/v1/engines/{ENGINE_NAME}/analytics/queries' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer private-xxxxxxxxxx' \
-d '{
"page": {
"size": 20
}
}'
Queries Filtering
指定回傳資料帶有 clicks 資訊
curl -X GET '{API_Endpoint}/api/as/v1/engines/{ENGINE_NAME}/analytics/queries' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer private-xxxxxxxxxx' \
-d '{
"filters": { "clicks": true }
}'
指定回傳資料不帶有 results 資訊
curl -X GET '{API_Endpoint}/api/as/v1/engines/{ENGINE_NAME}/analytics/queries' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer private-xxxxxxxxxx' \
-d '{
"filters": { "results": false }
}'
指定查詢帶有 single tag
curl -X GET '{API_Endpoint}/api/as/v1/engines/{ENGINE_NAME}/analytics/queries' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer private-xxxxxxxxxx' \
-d '{
"filters": { "tag": "web" }
}'
指定查詢帶有 multiple tags
curl -X GET '{API_Endpoint}/api/as/v1/engines/{ENGINE_NAME}/analytics/queries' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer private-xxxxxxxxxx' \
-d '{
"filters": { "tag": ["web", "mobile"] }
}'
用 POST 指定查詢一定時間範圍的結果
curl -X POST '{API_Endpoint}/api/as/v1/engines/{ENGINE_NAME}/analytics/queries' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer private-xxxxxxxxxx' \
-d '{
"filters": {
"date": {
"from": "2018-06-15T12:00:00+00:00",
"to": "2018-06-19T00:00:00+00:00"
}
}
}'
多個過濾條件
curl -X GET '{API_Endpoint}/api/as/v1/engines/{ENGINE_NAME}/analytics/queries' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer private-xxxxxxxxxx' \
-d '{
"filters": {
"all": [
{
"clicks": false
}, {
"results": true
}
]
}
}'
Full Example
完整過濾條件示範
curl -X GET '{API_Endpoint}/api/as/v1/engines/{ENGINE_NAME}/analytics/queries' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer private-xxxxxxxxxx' \
-d '{
"filters": {
"all": [
{
"clicks": false
}, {
"date": {
"from": "2018-06-15T12:00:00+00:00",
"to": "2018-06-19T00:00:00+00:00"
}
}, {
"results": false
}, {
"tag": ["web", "mobile"]
}
]
},
"page": {
"size": 20
}
}'
依降幕回傳一定時間內的點擊次數
GET /api/as/v1/engines/{ENGINE_NAME}/analytics/clicks
POST /api/as/v1/engines/{ENGINE_NAME}/analytics/clicks
Top Clicks
利用 GET 獲取過去七天前十名的熱門點擊次數, body 不帶任何參數
curl -X GET '{API_Endpoint}/api/as/v1/engines/{ENGINE_NAME}/analytics/clicks' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer private-xxxxxxxxxx' \
-d ''
Pagination
指定回傳資料的結果筆數
指定回傳 20 筆
curl -X GET '{API_Endpoint}/api/as/v1/engines/{ENGINE_NAME}/analytics/clicks' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer private-xxxxxxxxxx' \
-d '{
"page": {
"size": 20
}
}'
By Query
查看特定字詞的點擊次數
curl -X GET '{API_Endpoint}/api/as/v1/engines/{ENGINE_NAME}/analytics/clicks' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer private-xxxxxxxxxx' \
-d '{
"query": "花蓮"
}'
Clicks Filtering
查看特定時間內的最高點擊資料
curl -X GET '{API_Endpoint}/api/as/v1/engines/{ENGINE_NAME}/analytics/clicks' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer private-xxxxxxxxxx' \
-d '{
"filters": {
"date": {
"from": "2018-06-15T12:00:00+00:00",
"to": "2018-06-19T00:00:00+00:00"
}
}
}'
為查詢帶入 single tag
curl -X GET '{API_Endpoint}/api/as/v1/engines/{ENGINE_NAME}/analytics/clicks' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer private-xxxxxxxxxx' \
-d '{
"filters": { "tag": "web" }
}'
為查詢帶入 multiple tag
curl -X GET '{API_Endpoint}/api/as/v1/engines/{ENGINE_NAME}/analytics/clicks' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer private-xxxxxxxxxx' \
-d '{
"filters": { "tag": ["web", "mobile"] }
}'
多個過濾條件
curl -X GET '{API_Endpoint}/api/as/v1/engines/{ENGINE_NAME}/analytics/clicks' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer private-xxxxxxxxxx' \
-d '{
"filters": {
"all": [
{
"clicks": false
}, {
"results": true
}
]
}
}'
Full Example
完整過濾條件示範
curl -X GET '{API_Endpoint}/api/as/v1/engines/{ENGINE_NAME}/analytics/clicks' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer private-xxxxxxxxxx' \
-d '{
"filters": {
"all": [
{
"clicks": false
}, {
"date": {
"from": "2018-06-15T12:00:00+00:00",
"to": "2018-06-19T00:00:00+00:00"
}
}, {
"results": false
}, {
"tag": ["web", "mobile"]
}
]
},
"page": {
"size": 20
}
}'
以升幕方式回傳一天的總點擊數量和總查詢數。默認時間/日期格式是RFC3339。
GET /api/as/v1/engines/{ENGINE_NAME}/analytics/counts
POST /api/as/v1/engines/{ENGINE_NAME}/analytics/counts
Weekly Counts
回傳七天的總查詢與總點擊結果,一筆為一天的統計
curl -X GET '{API_Endpoint}/api/as/v1/engines/{ENGINE_NAME}/analytics/counts' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer private-xxxxxxxxxx' \
-d ''
完整過濾條件示範
curl -X GET '{API_Endpoint}/api/as/v1/engines/{ENGINE_NAME}/analytics/counts' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer private-xxxxxxxxxx' \
-d '{
"filters": {
"all": [
{
"tag": ["mobile", "web"]
},{
"query": "rails"
}, {
"document_id": "163"
}, {
"date": {
"from": "2018-07-05T12:00:00+00:00",
"to": "2018-07-05T14:00:00+00:00"
}
}
]
},
"interval": "hour"
}'
再次感謝大家閱讀,今天就先到這邊摟!明天見掰掰~