Aloha!又是我少女人妻 Uerica~!剛剛出門遛狗,遛著遛著結果鑰匙就掉了,找了兩小時還是找不到,想到小時候也常常丟三落四,我媽常常問我怎麼不弄丟自己,嗚嗚...小時候都覺得鑰匙掉了、要死掉了拉 QQ
Facets 篩選面板,有分為 Value 篩選 與 Range 篩選
使用類型需遵守以下表格
Type | Value Facet | Range Facet |
---|---|---|
text | Yes | No |
number | Yes | Yes |
date | Yes | Yes |
geolocation | No | Yes |
提供某欄位值的計數,可用於 text、number、date 三種欄位類型
curl -X POST '{API_Endpoint}/api/as/v1/engines/{ENGINE_NAME}/search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-xxxxxxxxxx' \
-d '{
"query": "花蓮",
"facets": {
//area 是 field key,要被篩選的欄位名稱
"area": [
{
"type": "count",
"name": "area",
"sort": { "value": "desc" },
"size": 5
}
]
}
}'
回傳結果
{
"meta": {
"alerts": [],
"warnings": [],
"page": {
"current": 1,
"total_pages": 4,
"total_results": 32,
"size": 10
},
"engine": {
"name": "6gogo",
"type": "default"
},
"request_id": "0737cd18-36b7-4d1f-beb3-747dce6fe6fd"
},
"results": [
// Truncated!
],
"facets": {
"area": [
{
"type": "value",
"name": "area",
"data": [
{
"value": "豐濱鄉",
"count": 1
},
{
"value": "花蓮市",
"count": 8
},
{
"value": "秀林鄉",
"count": 6
},
{
"value": "新城鄉",
"count": 2
},
{
"value": "壽豐鄉",
"count": 8
}
]
}
]
}
}
回傳某範圍內的計數,在number,date,geolocation欄位類型上可用。
number類型欄位的Range Facet
curl -X POST '{API_Endpoint}/api/as/v1/engines/{ENGINE_NAME}/search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-xxxxxxxxxx' \
-d '{
"query": "park",
"facets": {
"acres": [
{
"type": "range",
"name": "min-and-max-range",
"ranges": [
{ "from": 1, "to": 10000 },
{ "from": 10000 }
]
}
]
}
}'
date 類型欄位的Range Facet
curl -X POST '{API_Endpoint}/api/as/v1/engines/{ENGINE_NAME}/search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-xxxxxxxxxx' \
-d '{
"query": "park",
"facets": {
"date_established": [
{
"type": "range",
"name": "half-century",
"ranges": [
{ "from": "1900-01-01T12:00:00+00:00", "to": "1950-01-01T00:00:00+00:00" }
]
}
]
}
}'
geolocation 類型欄位的Range Facet
curl -X POST '{API_Endpoint}/api/as/v1/engines/{ENGINE_NAME}/search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-xxxxxxxxxx' \
-d'{
"query": "parks",
"facets": {
"location": [
{
"type": "range",
"name": "geo-range-from-san-francisco",
"center": "37.386483, -122.083842",
"unit": "m",
"ranges": [
{ "from": 0, "to": 100000, "name": "Nearby" },
{ "from": 100000, "to": 300000, "name": "A longer drive." },
{ "from": 300000, "name": "Perhaps fly?" }
]
}
]
}
}'
今天就先到這邊拉,感謝大家閱讀~祝福我鑰匙被好心人撿到,然後好心人剛好知道我在找鑰匙阿哈哈,大家明天見啦!掰掰