Aloha!我是少女人妻 Uerica!時間過得好快,鐵人賽只剩下十天拉~!
還記得我們前面提到欄位搜尋比重提升的概念嗎?所有搜尋結果的排序會依照美筆資料的 "score" 來計算, "score" 越高資料排序越前面,而提升 "score" 的操作細節我們就稱為 Boosts 。
提高搜尋欄位中某個值的score
curl -X POST '{API_Endpoint}/api/as/v1/engines/{ENGINE_NAME}/search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-xxxxxxxxxx' \
-d '{
"query": "heritage site",
"boosts": {
"world_heritage_site": [
{
"type": "value",
"value": "true",
"operation": "multiply",
"factor": 10
}
]
}
}'
應用函數來提升score值
curl -X POST '{API_Endpoint}/api/as/v1/engines/{ENGINE_NAME}/search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-xxxxxxxxxx' \
-d '{
"boosts": {
"visitors": {
"type": "functional",
"function": "logarithmic",
"operation": "multiply",
"factor": 2
}
},
"query": "popular parks"
}'
提升鄰近地理位置或接近指定數字的score
curl -X POST '{API_Endpoint}/api/as/v1/engines/{ENGINE_NAME}/search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-xxxxxxxxxx' \
-d '{
"boosts": {
"location": {
"type": "proximity",
"function": "linear",
"center": "25.32, -80.93",
"factor": 8
}
},
"query": "old growth"
}'
提升鄰近日期的score
curl -X POST '{API_Endpoint}/api/as/v1/engines/{ENGINE_NAME}/search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-xxxxxxxxxx' \
-d '{
"boosts": {
"date_established": {
"type": "proximity",
"function": "linear",
"center": "now",
"factor": 8
}
},
"query": "old growth"
}'
使用類型需遵守以下表格
Type | Value Boosts | Functional Boosts | Proximity Boosts | Recency Boosts |
---|---|---|---|---|
text | Yes | No | No | No |
number | Yes | Yes | Yes | No |
date | Yes | No | No | Yes |
geolocation | Yes | No | Yes | No |
感謝大家閱讀,明天見拉~掰掰