Elastic Workplace Search Quick Start 用三分鐘的時間架設工作區搜尋引擎

me
林彥成
2020-09-08 | 2 min.
文章目錄
  1. 1. Workplace Search 簡介
  2. 2. Workplace Search
  3. 3. Custom API Source
  4. 4. Workplace Search 設定

這篇文章會示範如何使用 Elastic Workplace Search (工作區檢索),工作區檢索讓我們能夠匯入並整合第三方服務的資料到搜尋引擎中,像是 Google Drive、Dropbox 等等,使用 Elastic Cloud 服務可以在幾分鐘內完成所有相關設定與資料匯入。

Workplace Search 簡介

為什麼需要工作區 (Workplace) 檢索

  • 整合的搜尋介面: 檔案散落在各大服務中,不一定會記得哪份文件放在哪裡
    • 跨部門檔案共享,檔案不一定是你建立的,相關文件往往很難找?
  • 優秀的分類篩選檢索,能更快找到某檔名的 pdf 的檔案

解決的痛點:

  • 開箱即用
  • 搜尋效能棒
  • 找文件不再大海撈針
  • 提供 Custom API Source 匯入相關內容
  • 可依群組調整權限與結果
    • 提供不同群組的結果權重調整

使用方式:

  • 新增資料源,這次使用 Dropbox,按照相關文件設定即可,其他資訊源大多也都類似以下步驟
  • 設定完成後就可以到 Search Application 中試用 (左側選單中最下面的放大鏡)

Connect 後可以看到檢索的內容 Summary
SourceOverview

Search Application 介面
WorkplaceSearchDropbox

Custom API Source

這部分比較特別,因為不是第三方所以不需要經過 OAuth,建立 Custom API Source 會得到 key 跟 token,接著就可以透過打 API 的方式新增資料。

建立 Custom API Source 介面
CustomAPISource

Curl 的範例如下,我們只需要把 URL 換成 Elastic Cloud,將 [KEY][AUTH_TOKEN] 換成我們剛剛得到的值,就可以將資料匯入。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
curl -X POST http://localhost:3002/api/ws/v1/sources/[KEY]/documents/bulk_create \
-H "Authorization: Bearer [AUTH_TOKEN]" \
-H "Content-Type: application/json" \
-d '[
{
"_allow_permissions": ["permission1"],
"_deny_permissions": [],
"id" : 1234,
"title" : "The Meaning of Time",
"body" : "Not much. It is a made up thing.",
"url" : "https://example.com/meaning/of/time",
"created_at": "2019-06-01T12:00:00+00:00",
"type": "list"
},
{
"_allow_permissions": [],
"_deny_permissions": ["permission2"],
"id" : 1235,
"title" : "The Meaning of Sleep",
"body" : "Rest, recharge, and connect to the Ether.",
"url" : "https://example.com/meaning/of/sleep",
"created_at": "2019-06-01T12:00:00+00:00",
"type": "list"
},
{
"_allow_permissions": ["permission1"],
"_deny_permissions": ["permission2"],
"id" : 1236,
"title" : "The Meaning of Life",
"body" : "Be excellent to each other.",
"url" : "https://example.com/meaning/of/life",
"created_at": "2019-06-01T12:00:00+00:00",
"type": "list"
}
]'

當然也可以寫程式或透過 GUI 像是 RestEasy 打資料進去
AddDataToCustomAPI

Workplace Search 設定

設定資料來源後 Workplace Search 也提供了好幾種的設定,可以調整的部分如下:

  • Group: 可以建立資料分類群組
    • SourcePrioritization: 針對群組檢索的結果進行權重配置
  • Role Mappings: 角色的分配

Group,舉例來說可以分成工程師、PM、行銷三種群組

資料群組分類
ManageGroup

SourcePrioritization,每個人想要看到的內容可能優先權不太一樣。

  • 工程師 => 規格書優先 (Dropbox + Github)
  • PM、行銷 => 企畫書優先 (Google Drive)

檢索的結果進行權重配置
SourcePrioritization

Role Mappings: 分完群組後就可以進行角色配置,將角色對應到剛剛的群組

角色配置
RoleMappings


喜歡這篇文章,請幫忙拍拍手喔 🤣


share