ElasticSearch Introduction

21
Copyright © Elitegroup Computer Systems. All Rights Reserved Page1 組組組組 Open Source Technologies for Search Engine 組組組 marr 2014/07/1 5 組組組組組組組組組組組組 Case Study on ElasticSearch

TAGS:

description

How ElasticSearch Can Be Used or What Benefits for Integrators

Transcript of ElasticSearch Introduction

Page 1: ElasticSearch Introduction

Copyright © Elitegroup Computer Systems. All Rights Reserved Page1

組內報告

Open Source Technologies for Search Engine

胡崇偉 marr2014/07/15

雲端時代的資料索引與搜尋Case Study on ElasticSearch

Page 2: ElasticSearch Introduction

組內報告 2012/10/30 2

搜尋引擎的角色 常見於整合式大系統裡 用以協助使用者快速存取需要的內容 提供第一線服務的搜尋服務 收集使用者貢獻的資料進行分析功能

EEA 搜尋功能轉往結合 ElasticSearch CKAN 使用 ElasticSearch 圖書管理系統 Koha 使用 Lucene/Solr GitHub 使用 ElasticSearch Netflix 使用 ElasticSearch

Page 3: ElasticSearch Introduction

組內報告 2012/10/30 3

解決怎樣的問題 ? 同義詞 ( 語意 ) 搜尋

搜尋「媽祖」回傳包括「天上聖母」的資料 依權重分數 ( 例 : 使用者角色 ) 調整排序結果

依地理資訊搜尋 選定座標中心搜尋特定距離的資料 顯示額外資訊提示使用者需要的資料

即時分析搜尋 / 社群資料 整合視覺工具呈現統計結果

降低開發 / 訓練 / 管理的整體成本 效能延展並提供一致的開發機制 (API, 資料格式 )

Page 4: ElasticSearch Introduction

組內報告 2012/10/30 4

同義詞 ( 語意 ) 搜尋

Analyzer 可視為斷字斷詞工具

Relational Database RDF Data Model ElasticSearch傳統使用 Keyword 比對,擴充 Schema / Column / SQL 來建立關連的同義詞

需事先建立夠完整的知識體系,再利用 SPARQL 之類的工具

利用 Tokenizer, Token Filter, Character Filter 來建立 Analyzer 進行搜尋

Page 5: ElasticSearch Introduction

組內報告 2012/10/30 5

Analyzer 範例 #1

snowball

Page 6: ElasticSearch Introduction

組內報告 2012/10/30 6

Analyzer 範例 #2

snowball

Page 7: ElasticSearch Introduction

組內報告 2012/10/30 7

建立同義詞表# This is a SOLR synonym file台北縣 => 新北市媽祖 , 天上聖母 , 天后文山區 => 景美 , 木柵

Page 8: ElasticSearch Introduction

組內報告 2012/10/30 8

同義詞設定語法{“index”: { “analysis”: { “analyzer”: { “my_names”: { “tokenizer”: “whitespace”, “filter”: [“my_synonym”] } }, “filter”: { “my_synonym”: { “type”: “synonym”, “synonyms_path”: “analysis/synonym.txt” } }

Page 9: ElasticSearch Introduction

組內報告 2012/10/30 9

依權重分數調整排序結果 ES 給分的方式大致有四種 : 文件的詞數 ( 長度 ) 詞在文件內的頻率 詞在索引內的頻率 任意指定

以使用者角色為例 : 研究人員優先回傳學術著作的相關資料

Page 10: ElasticSearch Introduction

組內報告 2012/10/30 10

依地理資訊搜尋

選定座標中心搜尋特定距離的資料 顯示額外資訊提示使用者需要的資料

Page 11: ElasticSearch Introduction

組內報告 2012/10/30 11

即時分析搜尋 / 社群資料

利用 Logstash 即時分析搜尋結果 利用 Kibana 呈現事件趨勢

Page 12: ElasticSearch Introduction

組內報告 2012/10/30 12

利用 Kibana 建立 Dashboard

LinkedIn dana

Page 13: ElasticSearch Introduction

組內報告 2012/10/30 13

與資料庫進行類比

Mapping 是指可搜尋的範圍,建立 Type 與Field 時就會自動產生 Mapping ,預設就可搜尋

Document 是巢狀結構,不像 RDBMS 的 Row 只是二維表 都可以執行 CRUD 動作

Relational DB ElasticSearchDatabase Index

Table Type

Row Document

Column Field

Schema Mapping

Index Everything is Indexed

SQL Query Domain-Specific Language

Page 14: ElasticSearch Introduction

組內報告 2012/10/30 14

類似產品的比較Lucene Solr ElasticSearch Zoie

Java 搜尋函式庫

企業級搜尋方案

重新設計過的後起之秀

由 LinkedIn 開發

著重底層功能 著重實用性 著重易用性 經歷完整測試和市場驗證

適於自行開發產品、需要高效能的場合

適於企業開發環境

適於低成本的開發環境

適於快速回應使用者的應用場合

Page 15: ElasticSearch Introduction

組內報告 2012/10/30 15

ElasticSearch

CMS Database

分散式搜尋

SQL Database

Page 16: ElasticSearch Introduction

組內報告 2012/10/30 16

優勢及應用建議 適合跨系統整合或大量資料的搜尋和索引

Distributed and Scalable Nodes 降低系統應用的學習 / 溝通成本

Intuitive and Simple: JSON, REST APIs Interoperation with Non-Java/JVM Languages

降低整體開發成本 Gateway makes Full Backup easier Work with Cloud Services: Hadoop, S3

Page 17: ElasticSearch Introduction

組內報告 2012/10/30 17

應用限制 個別資料的頻繁變動會造成效能低落 分散系統裡的 Shard 無法有效處理變更大小的需求 缺乏權限管理機制

Page 18: ElasticSearch Introduction

組內報告 2012/10/30 18

報告完畢

檔案後附參考資訊

Page 19: ElasticSearch Introduction

組內報告 2012/10/30 19

發展歷史 1997: Lucene Developed by Doug

Cutting 2000: Open Source under GPL 2001: Invited to Apache Jakarta 2004: Promoted to Apache

TopLevelProject 2006: Solr Joins Lucene 2010: ElasticSearch Released by Shay

Banon 2013: Search in Hadoop Platform

Page 20: ElasticSearch Introduction

組內報告 2012/10/30 20

新增索引範例curl –XPUT ‘http://localhost:9200/twitter/tweet/1’ –d ‘{“user”: “marr”,“post_date”: “2014-06-30T10:12:12”,“message”: “trying out ElasticSearch”}’

{“_index”: “twitter”,“_type”: “tweet”,“_id”: “1”,“_version”: 1,“created”: true}

Page 21: ElasticSearch Introduction

組內報告 2012/10/30 21

Faceted View ElasticSearch + Faceted View

http://centaurus-dev.eea.europa.eu/pam