iT邦幫忙

第 12 屆 iThome 鐵人賽

DAY 29
1
Elastic Stack on Cloud

少女人妻的30天Elastic系列 第 29

【少女人妻的30天Elastic】Day 29 : App Search_API 介紹與應用_Curations

Aloha!我是少女人妻 Uerica!這個週末朋友要求婚了~朋友前陣子喝了一點然後問我婚姻的感覺是什麼?我回他你想要婚姻是什麼樣子,那就會是什麼樣子。人與人相處終究都是強迫認識自己的過程,不過結婚也好單身也好,無論什麼樣的狀態,我都還是自己啊~價值不因外在改變而改變,人生才會過得快樂呢~~

Curations API

有關Curations的運用與介紹

Curations 隱藏與提升搜尋結果的內容
Curations 的翻譯是策展,其實就是專門管理搜尋結果的推廣 Promoted 與隱藏 Hidden。

認證方式為 Private API Key

curl -X GET '{API_Endpoint}/api/as/v1/engines/{ENGINE_NAME}/curations' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer private-xxxxxxxxxx' \

List Curations 列出策展 GET

Listing All Curations 列出所有策展

回傳所有調整過的策展內容

page (optional) : 回傳當前頁面 current 、結果總頁數 total_pages 、結果總筆數 total_results 、每頁最大筆數限制 size (預設為25筆)

用 GET 方法,不帶參數回傳所有策展結果

curl -X GET '{API_Endpoint}/api/as/v1/engines/{ENGINE_NAME}/curations' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer private-xxxxxxxxxx' \
-d ''

Listing All Curations with Pagination

指定回傳的頁數與筆數

curl -X GET '{API_Endpoint}/api/as/v1/engines/{ENGINE_NAME}/curations' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer private-xxxxxxxxxx' \
-d '{
  "page": {
    "size": 20,
    "current": 2
  }
}'

Listing a Single Curation

回傳指定id的策展資料

用 GET 方法,帶入id不需參數,回傳指定的策展資料

curl -X GET '{API_Endpoint}/api/as/v1/engines/{ENGINE_NAME}/curations/[CURATION_ID]' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer private-xxxxxxxxxx' \
-d ''

Create Curations 創建新策展 POST

  • queries (required) : 可以提供一個或多個同義字查詢,但一次只能創建一種字詞的查詢
  • promoted (optional) : 提供要 promoted 的資料
  • hidden (optional) : 提供要 hidden 的資料

用 POST 創建新策展

curl -X POST '{API_Endpoint}/api/as/v1/engines/{ENGINE_NAME}/curations/[CURATION_ID]' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer private-xxxxxxxxxx' \
-d '{
  "queries": [
    "banana", "bananana", "bonana", "nanner"
  ],
  "promoted": [
    "doc-123", "doc-234", "doc-345"
  ],
  "hidden": [
    "doc-987", "doc-a8b7c6", "doc-765"
  ]
}'

範例回傳結果

{
  "id": "cur-a1b2c3"
}

Update Curations 更新策展 PUT

用 PUT 更新策展資訊

curl -X PUT '{API_Endpoint}/api/as/v1/engines/{ENGINE_NAME}/curations/[CURATION_ID]' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer private-xxxxxxxxxx' \
-d '{
  "queries": [
    "banana", "bananza", "bananas", "bonana"
  ],
  "promoted": [
    "doc-a1b2c3", "doc-a3b3c4", "doc-445"
  ],
  "hidden": [
    "doc-a9b8c7"
  ]
}'

Delete Curations 刪除策展 DELETE

用 DELETE 刪除指定id的策展

curl -X DELETE '{API_Endpoint}/api/as/v1/engines/{ENGINE_NAME}/curations/[CURATION_ID]' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer private-xxxxxxxxxx' \
-d ''

感謝閱讀,今天就到這邊拉~明天就是最後一篇文章了,真是讓人捨不得啊!


上一篇
【少女人妻的30天Elastic】Day 28 : App Search_API 介紹與應用_Analytics
下一篇
【少女人妻的30天Elastic】Day 30 : App Search_API 介紹與應用_Synonyms
系列文
少女人妻的30天Elastic30

尚未有邦友留言

立即登入留言