Elasticsearchã®Indexãæ¬å½ã®æå³ã§ç¡åæ¢åæ§ç¯ããææ³
â» ãã®è¨äºã¯ Elastic stack (Elasticsearch) Advent Calendar 2017 ã®2æ¥ç®ã®è¨äºã«ãªãã¾ãã
Elasticsearchãå©ç¨ãããµã¼ãã¹ãéç¨ãã¦ããå ´åãæ¢åæ©è½ã®æ¹ä¿®ãä»æ§å¤æ´ãæ°è¦æ©è½ã®å®è£ ã«ä¼´ããéç¨ä¸ã§ãã£ã¦ãindexãæ¤ç´¢ã¯ã¨ãªãå¤æ´ãã¦ãããã¨ã¯æ¥ã çºçãã¾ãããã®éã«ãã¤ã³ããã¯ã¹ãåæ§ç¯ããå¿ è¦æ§ãåºã¦ãã¾ãããã¤ã³ããã¯ã¹ãåæ§ç¯ããããã«æ´åæ§ã®ãããã¼ã¿ã»ãããæºåããã®ã«ã¯æéããããã¾ãããã®é½åº¦ã¡ã³ããã³ã¹ãè¡ãã®ã¯éç¾å®çã§ãããç¹ã«å¤§è¦æ¨¡ãµã¼ãã¹ã§ããã°æºåã«ãããæéèªä½ãéç¾å®çãªãã®ã«ãªãããã¾ããã
ãã®ãããªåé¡ã¸ã®å¯¾å¦æ¹æ³ã¨ãã¦ã Index Aliases ãå©ç¨ãããã¨ã§ãééçã«ç¡åæ¢åæ§ç¯ãè¡ããã¨ãåºæ¥ãã¨ããã®ã¯è¤æ°ã®ããã°è¨äºã§ç´¹ä»ããã¦ãã¾ãããããã¯ã¢ããªã±ã¼ã·ã§ã³ããç´æ¥indexãå©ç¨ããã®ã§ã¯ãªããaliasãçµç±ãã¦å©ç¨ãããã¨ã§ãç¡åæ¢åæ§ç¯ãè¡ããã¨ããææ³ã§ãã
ãããã«ãshardæ°ã®å¤æ´ã§ãã£ããã Analyzer ã Tokenizer ã¬ãã«ã®ä¿®æ£ã§ããã°ã Index Aliasãå©ç¨ããç¡åæ¢åæ§ç¯ã¯å©ä¾¿æ§ã®é«ãææ³ã§ããIndex Alias ãæã¤ééæ§ã«ãããã¢ããªã±ã¼ã·ã§ã³ãã¸ãã¯ãå¤æ´ããã«ãã¤ã³ããã¯ã¹ãåæ§ç¯ãããã¨ãåºæ¥ã¾ãã
ããããªãããæ°è¦fieldã®è¿½å ãæ¢åfieldã®å¤æ´/ç ´æ£ãè¡ããæ¤ç´¢ã¯ã¨ãªãå¤æ´ããã¨ãã£ãã¬ãã«ã§ã®éçºãè¡ãå ´åãIndex Aliases ãå©ç¨ããç¡åæ¢åæ§ç¯ã¯æåã®ææ³ã§ã¯ãªããªãã¾ãããã®è¨äºã«ããã¦ã¯ãã¨ã³ãã¦ã¼ã¶ã¼ã«ã¹ã ã¼ãºãªä¾¡å¤æä¾ãè¡ãããã«ãé«ãéçºå¹çãç¶æãã¤ã¤ããã¤ã³ããã¯ã¹ãç¡åæ¢ã§åæ§ç¯ããææ³ã«ã¤ãã¦ææ¡ãããã¨æãã¾ãã
TL;DR
- è¨è¨
- RDBMSãªã©ã®ä»ã¬ã¤ã¤ã¼ã§ãã¹ã¿ã¼ã¨ãã¦ã®ãã¼ã¿æ°¸ç¶å層ãå®ç¾ããElasticsearchã¯ãã¼ã¿ãæ¤ç´¢ããããã®æ°¸ç¶å層ã¨ãã¦è²¬åãåæ ããã
- ã¢ããªã±ã¼ã·ã§ã³ã§ã¯ãModelãEntityã«å¯¾ãã¦ãElasticsearchã¸ã®ãã¼ã¿ä¿åã»æ¤ç´¢ãæ ãRepositoryãå®ç¾©ãã
- Modelã«å¯¾ã㦠m : n 㧠Repository ãå®ç¾©ã§ããRepositoryã¯ä¿åç¨ã»æ¤ç´¢ç¨ã§å¥ã®ãã®ãå©ç¨ã§ããããã«ãã¦ãã (æä½éã®éçºã§ããã° 1 : n ã§è¯ã)
- Repositoryã¨index㯠1 : 1 ã®é¢ä¿ã§å©ç¨ã§ããããã«ãã¦ãã
- ã¤ã³ããã¯ã¹åæ§ç¯ãªãã¬ã¼ã·ã§ã³
- Elasticsearchä¸ã«æ°ããindexãæ§ç¯ããæ°/æ§2ã¤ã®indexãå©ç¨å¯è½ãªç¶æ ã«ãã
- ä¿åç¨ã®Repositoryããæ°/æ§2ã¤ã®indexã«å¯¾å¿ãã2ã¤ã®Repositoryã«ããããã®æç¹ä»¥éã«æä½ããããã¼ã¿ã¯æ°indexã«ãä¿åããå§ãã
- ãã¼ã¿ãå 足ãããã¾ã§ã¯ãæ¤ç´¢ç¨ã®Repositoryã¯æ§indexã®ãã®ãå©ç¨ãã¤ã¥ãã
- ããããªã©ããBulk API ãå©ç¨ãã¦ãæªæä½ã®ãã¼ã¿ã®åæãè¡ã
- ãã®éãOperation Type ãå©ç¨ãã楽観ããã¯ãè¡ããã¨ã«ããããµã¼ãã¹çµç±ã§æ´æ°ããããã¼ã¿ã¨ã®æ´åæ§ãä¿ã¡ã¤ã¤ãæªå¦çã®ãã¼ã¿ã«ã¤ãã¦ã®ã¿åæãè¡ã
- ãã¼ã¿åæå®äºå¾ãæ¤ç´¢ãã¸ãã¯ãå¤ãããã¿ã¤ãã³ã°ã§ãæ¤ç´¢ç¨Repositoryãæ°indexç¨ã®ãã®ã«å¤æ´ãã
- ä»»æã®ã¿ã¤ãã³ã°ã§æ§indexã¸ã®ä¿åãåæ¢ããæ§indexãç ´æ£ãã
æºããã¹ãç¡åæ¢åæ§ç¯ã®è¦ä»¶ã«ã¤ãã¦
æ¬è¨äºã§ç¡åæ¢åæ§ç¯ã¨è¨ã£ãå ´åã«ä½ã示ãã¦ãããã«ã¤ãã¦ã以ä¸ã«è¨è¿°ãã¾ãã
- æ§ã¤ã³ããã¯ã¹ãå©ç¨ããã¢ããªã±ã¼ã·ã§ã³ã¯ãå®å ¨ã«ã¢ããªã±ã¼ã·ã§ã³ãåãæ¿ããã¾ã§ãã³ã¼ãã®ä¿®æ£ãªãæ£å¸¸ã«åä½ãããã¨
- æ§ã¤ã³ããã¯ã¹ã¯ã¤ã³ããã¯ã¹åæ§ç¯ä¸ã常ã«ææ°ã®ãã¼ã¿ã§æ´æ°ããç¶ãããã¨
- æ§ããæ°ã¸ã®ã¢ããªã±ã¼ã·ã§ã³ã®åãæ¿ãã¯ããã»ã¹åä½ã§ã¢ãããã¯ã«è¡ãããæ§ã¤ã³ããã¯ã¹ãåç §ãã¦ããæ§ããã»ã¹ãæ£å¸¸ã«åä½ãããã¨
- æ°ã¤ã³ããã¯ã¹ã¯ã¤ã³ããã¯ã¹åæ§ç¯ä¸ã«æ´æ°ããããã¼ã¿ãå«ãã¦ææ°ã®ç¶æ ã§æå ¥ããããã¨
- æ°ã»æ§ããããã®ã¤ã³ããã¯ã¹ä¸ã«åå¨ãããã¼ã¿ã¯å¿ è¦ååãªéã«éå®ããã移è¡ã«ä¼´ããªã¼ãã¼ãããããªã¹ã¯ãæå°ã«ãªããã¨
- ä¸è¨ãæºãããä¸ã§ãéçºã»éç¨ãããå¹çåãããã¨
å ·ä½çãªä¾ã«ã¤ãã¦
æ½è±¡çãªè©±ã°ããã§ã¯åããã¥ããã¨ãããã¨ãããããã以ä¸ã®ã·ãã¥ã¨ã¼ã·ã§ã³ãç°¡åãªä¾ã¨ãã¦åãä¸ãã¾ãã
- ã¦ã¼ã¶ã¼
user
ãã¢ã«ã¦ã³ãåaccount_name
ã§æ¤ç´¢ããããã«Elasticsearchãå©ç¨ãã¦ãã account_name
ã®æ¤ç´¢ã ãã§ã¯ãéã¢ã¯ãã£ããªã¦ã¼ã¶ã¼ãããããã¦ãã¾ããããæçµãã°ã¤ã³æ¥last_login
ã1ã¶æ以å ã®ã¦ã¼ã¶ã¼ã«çµãæ©è½ãå¿ è¦ã«ãªã£ã
ä¾ã«éã£ã¦è¨ãã°ãä¸è¬çãªç¡åæ¢åæ§ç¯ã®ææ³ã§ã¯ãªããå¥ã®è§£æ±ºçãé©ãã¦ããã¨ããç¹ãããã¾ããããã®è¨äºã§ã¯ä¸è¬çãªè§£æ±ºçãç´¹ä»è´ãã¾ãã ã¾ããå®è£ ãµã³ãã«ã¨ã㦠Ruby on Rails + elasticsearch-rails ã®çµã¿åãããåãä¸ãããã¨æãã¾ãã
ã©ãã㦠Index Aliases ãæåã§ã¯ãªãå ´åãããã®ãï¼
Index Aliases ãæåã®é¸æè¢ã§ã¯ãªããªãã®ã¯ããã®ééæ§ãç¡æå³ã¨ãªãå ´åãããã¨ãã§ãã ã¢ããªã±ã¼ã·ã§ã³ããåç §ãã¦ããã¨ã¤ãªã¢ã¹åã¯åä¸ã ããElasticsearchã®å é¨çã«ã¯Aliasãæãã¦ããIndexã¯ç°ãªãã¨ããç¹ãIndex Aliasesã®ãã¨ãã¨ã®å©ç¹ã§ãã mappingã®å¤é¨æ§é ã«ã»ã¨ãã©å¤åããªããã°ãaliasãéãã¦ä¿åãããããã¥ã¡ã³ãã¯ç»é²ããã¦ããå ¨ã¦ã®indexã«ä¿åãããæ¤ç´¢ã¯ã¨ãªã¯ç»é²ããã¦ããå ¨ã¦ã®indexããè¡ããã¾ãã
éã«è¨ãã°ãæ°ã»æ§ã®indexã§fieldã®åã大ããç°ãªãå ´åããæ°ã»æ§ã®indexã§åå¨ããªãfieldãããå ´åã¯ãããã®å©ç¹ã¯å¤±ããã¾ããaliasãéããããä¸æ¹ã¸ã®indexã¸ã®ä¿åã¯ãä½åãªãã¼ã¿ã®çæã誤ã£ãmappingã®èªåä½æãã¨ã©ã¼ãªã©ã«ã¤ãªããã¾ããã¾ããindex 㨠æ¤ç´¢ã¯ã¨ãªãä¸è´ããªããã°ãæ³å®ããªãçµæï¼ã¤ã¾ããã°ï¼ã«ã¤ãªããã¾ãã
ã¦ã¼ã¶ã¼æ¤ç´¢ã®ä¾ã®å ´åãæ°ã»æ§ã®indexä¸ã®mappingsä¸ã®propertiesã¯ä»¥ä¸ã®ããã«ãªãã¾ãã
æ§ index
{ "user" : { "properties" : { "account_name" : { "type" : "keyword" } } } }
æ° index
{ "user" : { "properties" : { "account_name" : { "type" : "keyword" }, "last_login" : { "type" : "date" } } } }
ããã¦æ°ãã«æ¤ç´¢ã¯ã¨ãªã® filter ã«ä»ãå ããç¯ã¯ä»¥ä¸ã«ãªãã¾ãã
{ "range": { "last_login": { "gt": "2017/11/02" } } }
ä¸è¨ãè¦ã¦ããã ãã¨ãããããã«ãæ§indexã«ã¯ last_login
ã¯åå¨ãã¾ããã
ãã®çºãæ§indexã« last_login
ãä¿åãããã¨ããã°ã dynamic ã®è¨å®ã«ä¾åãã¾ãããæ§è½ä¸ã®ãªã¼ãã¼ãããããã¼ã¿ä¸æ´åãã¨ã©ã¼ã«ã¤ãªããã¾ãã
ã¾ããæ° index ã«æããã¯ãã®ã¯ã¨ãªã æ§index ã«æããããå ´å㯠last_login
ãããããåå¨ããªããããæ¤ç´¢çµæã0件ã«ãªã£ã¦ãã¾ãã¾ãã
ä¸è¬çã«ãAliasã®åãæ¿ããåæ並åã§å®è¡ããã¦ããã¢ããªã±ã¼ã·ã§ã³ã§ã¢ãããã¯ã«ãã³ããªã³ã°ãããã¨ã¯é£ãããIndex Aliases ã使ã£ãç¡åæ¢åæ§ç¯ã¯ç ´ç¶»ãã¦ãã¾ãã¾ãã
è¨è¨
ããã§ãã¢ããªã±ã¼ã·ã§ã³ã¬ã¤ã¤ã¼ã§å¯¾è±¡ã®indexãæ示çã«æå®ãã¦æ±ãææ³ãæ¬è¨äºã§ã¯ææ¡ãã¾ãã
責ååæ ã«ã¤ãã¦
Elasticsearch ãç¨ããæ¤ç´¢ãè¡ãå ´åãã·ã¹ãã ã¨ãã¦ã®ãã¼ã¿æ°¸ç¶å㯠RDBMS ãªã©ã®Elasticsearchå¤ã§è¡ããElasticsearchã¯æ¤ç´¢ã®ããã®æ°¸ç¶å層ã¨ãã¦è²¬åãæããã¾ããããã¯Elasticsearchãæ¤ç´¢ç¨ã®ã·ã¹ãã ã¨ãã¦æé©åããç ´å£çãªå¤æ´ãæ¬æ¥ã®ãã¼ã¿æ§é ã示ãã¦ããªãmappingã§ãã£ã¦ã容æã«ä½æå¯è½ã«ããããã§ãã
Repositoryã®è¨è¨ã«ã¤ãã¦
責ååæ ãè¡ã£ãä¸ã§ã以ä¸ã®ãããªRepositoryã®å°å ¥ãè¡ãã¾ãã
Repositoryã¯ã¢ããªã±ã¼ã·ã§ã³ã§å©ç¨ããModelãããã¯EntityãElasticsearchã®ç¹å®ã®indexã«ä¿å/æ¤ç´¢ããã¨ãã責åãæã¡ã¾ãããã®ããã«ãããã¨ã«ãã£ã¦ãæ§indexã¨æ°indexã«é¢ãããã¸ãã¯ãççµåã«åãããããããé«ãåé度ã§å®è£ ãããã¨ãå¯è½ã«ãªãã¾ãã
ã¾ããModel 㨠Repository ã m : n ã®é¢ä¿ã«ãããã¨ã«ãã£ã¦ãä¸ã¤ã®Model ãã©ã¡ãã® index ããåå¾ããããã©ã¡ãã«ä¿åãããã¨ããé¸æãã¢ããªã±ã¼ã·ã§ã³ã¬ã¤ã¤ã¼ã§ç°¡åã«æä½ã§ããããã«ãªãã¾ãã
ã¦ã¼ã¶ã¼æ¤ç´¢ã®ä¾ã«å¯¾ãã¦ãRuby on Rails 㨠Elasticsearch::Persistence ã® Repository Pattern ãå©ç¨ããã³ã¼ãä¾ã示ãã¾ãã Elasticsearch::Model ãRailsã¨ã®ç¸æ§ã¯è¯ãå å®ããæ©è½ãæã£ã¦ãã¾ãããç¡åæ¢åæ§ç¯ãè¡ãä¸ã§ã¯ Elasticsearch::Persistence ã®æ¹ãããããã§ãã
ç°¡åã®çºã« 1 : n ã®é¢ä¿ã«ãã¦ãã¾ãããRepositoryã¯ã©ã¹ã«indexã«é¢ããæä½ãéç´ããã¦ãããã¨ããããã¾ãã
# Model class class User < ActiveRecord::Base def self.repositories_to_save @repositories_to_save ||= [ ::ElasticRepository::UserV1.new, # ::ElasticRepository::UserV2.new, ] end after_save do self.class.repositories_to_save.each do |repository| repository.save(self) end end end # Repository Class module ElasticRepository # This unofficial inheritance usage increases flexibility especially when instance objects have their own customized settings class UserV1 < Elasticsearch::Persistence::Repository::Class def initialize client Elasticsearch::Client.new url: 'localhost:9200', log: true index 'user_v1' type 'user' settings number_of_shards: 1 do mapping do indexes :account_name, type: :keyword end end klass User end def deserialize(document) hash = document['_source'] klass.new(account_name: hash['account_name']).tap(&:readonly!) end def serialize(document) { id: document.id, account_name: document.account_name, } end def search_by_account_name(account_name) search( query: { bool: { filter: [ { term: { account_name: account_name } } ] } } ) end end end # Save (Save Record to DB and Index Documents to Elasticsearch) user = User.create!(account_name: 'foo') # When searching with old logic and old index ElasticRepository::UserV1.new.search_by_account_name('foo') # When searching with new logic and new index ElasticRepository::UserV2.new.search_by_account_name('foo', last_login: 1.month.ago)
ãã®ããã«ãããã¨ã§ãæ°/æ§ã®ãã¸ãã¯ãã¢ããªã±ã¼ã·ã§ã³ã¬ã¤ã¤ã¼ã§é©åã«æ±ããã¨ãã§ããããã«ãªãã¾ãã
ã¤ã³ããã¯ã¹åæ§ç¯ã®ãªãã¬ã¼ã·ã§ã³
ä¸è¿°ããRepositoryãè¨è¨ããã°ãã¤ã³ããã¯ã¹ã®åæ§ç¯ä½æ¥ã¯å®¹æãã¤ã¢ãããã¯ã«è¡ãã¾ãã
æ°ã¤ã³ããã¯ã¹ã®ä½æ
ã¾ãã¯æ°ããindexãä½æãæ¸ãè¾¼ã¿ãå¯è½ãªç¶æ ã«ãã¾ããElasticsearchã§ã®indexä½æã¯é常ã«è»½ããªãã¬ã¼ã·ã§ã³ã§ãããããå®ç¾©æ¸ã¿ã®ãã®ã«ã¤ãã¦ã¯ãdeployæãªã©ã«èªåçã«åæ ãããããã«ããå½¢ã楽ã§ãããã
ã¦ã¼ã¶ã¼æ¤ç´¢ã®ä¾ã§ã¯Capistranoãªã©ã§ã®deployæã«ä»¥ä¸ã®ã³ã¼ãã常ã«å®è¡ããããã«ãã¦ããã ãã§ãã®ã¹ãããã¯å®äºã§ãã
User.repositories_to_save.each(&:create_index!) # This internally checks if the index already exists or not.
æ°ã»æ§ä¸¡ã¤ã³ããã¯ã¹ã¸ã®æ¸ãè¾¼ã¿éå§
ã¤ãã«ãModelã¯ã©ã¹ã®ä¿åæã«å©ç¨ãããRepositoryãæ°ã»æ§ã®ä¸¡æ¹ã«ãã¾ãã
ãã®ã¢ããªã±ã¼ã·ã§ã³ã³ã¼ããdeployãããå¾ã¯ãæ°indexã«ã¤ãã¦ãææ°ã®ãã¼ã¿ãä¿åãããããã«ãªãã¾ãã
ã¦ã¼ã¶ã¼æ¤ç´¢ã®ä¾ã§ã¯ã User.repositories_to_save
ã®ä¸ã«ããã³ã¡ã³ãã¢ã¦ããå¤ãã ãã§å®äºãã¾ãã
å ¨ãã¼ã¿ã®åæ
ä¸è¨ã¢ããªã±ã¼ã·ã§ã³ã³ã¼ããdeployãããå¾ã«æä½ããããã¼ã¿ã«é¢ãã¦ã¯ãåºæ¬çã«ã¯ææ°ã®æ å ±ãæ°indexã«ãä¿åãããããã«ãªãã¾ãã ä¸æ¹ãã¢ããªã±ã¼ã·ã§ã³ã§ã¢ã¯ã»ã¹ããã¦ããªãä¼ç ã¬ã³ã¼ãã«ã¤ãã¦ã¯ããããå¦çãªã©ã§ã®åæãå¿ è¦ã«ãªãã¾ãã
ãã®éã«ã¯ Elasticsearch ã® Bulk API ãå©ç¨ãã¦è¤æ°ã¬ã³ã¼ããåæã«ä¿åãããã¨ã§é«ãå¹çãå¾ããã¨ãå¯è½ã«ãªãã¾ãã
ããããããã§ä¸ã¤ã®åé¡ã解決ããå¿
è¦ãããã¾ããããã¯é常ã®ã¢ããªã±ã¼ã·ã§ã³å´ã§ã®æ´æ°ã¨ãããã«ããæ´æ°ãåæã«è¡ãããéã«ãææ°ã®ãã¼ã¿ãæ´åæ§ã®ããç¶æ
ã§ä¿åããªããã°ãªããªãã¨ãããã¨ã§ãã幸ããªãã¨ã«Elasticsearchã«ã¯ Operation Type ã®è¨å®ãå¯è½ã§ãããããããã®æ´æ°ã«ã¯
op_type=create
ãä¸ãããã¨ã«ãã£ã¦ãã¢ããªã±ã¼ã·ã§ã³å´ã®æä½ã§æ°ãããªã£ããã¼ã¿ãå¤ããã¼ã¿ã§èª¤ã£ã¦ä¸æ¸ãããã¨ãããã¨ãé¿ãããã¾ããå®éã®éç¨ã«ããã¦ã¯ãå
¨ã¦ã®ã¬ã³ã¼ãã«å¯¾ãã¦ãã®å¦çãè¡ã£ã¦ãããã¨ã§ç°¡åã«æºåãããã¨ãå¯è½ã§ãã
ã¾ããBulkã«ããæ´æ°é度ãæ©ãããå ´åã«ã¯rejectãããå ´åãããã®ã§ãé©å®èª¿æ´ãè¡ã£ã¦ãã ããã
æ¤ç´¢ç¨ã¤ã³ããã¯ã¹ã®åãæ¿ã
å ¨ãã¼ã¿åæç¨ã®ãããå¦çãå®äºããã°ãæ°ã¤ã³ããã¯ã¹ã«ãå®å ¨ãªãã¼ã¿ãã¼ã¿ã»ãããæã£ã¦ããã¯ãã§ãã ã¢ããªã±ã¼ã·ã§ã³ä¸ã§ã®æ¤ç´¢é¨åãæ°Repositoryãå©ç¨ãããã®ã«ç½®ãæããã°ããããdeployãããç¬éã«ãæ°ããindex, æ°ããlogicã®çµã¿åããã§æ¤ç´¢ãè¡ãããããã«ãªãã¾ãã
Index Aliases ã¨ç°ãªããæ§ã¢ããªã±ã¼ã·ã§ã³ã¯æ§indexã¨æ§logicã®çµã¿åããã§åãç¶ãã¦ããã®ã§ãdeployæã«åé¡ãçºçãããã¨ãããã¾ããã
ã¦ã¼ã¶ã¼æ¤ç´¢ã®ä¾ã«ããã¦ã¯ãä¸è¿°ããã³ã¼ãã®æå¾ã®é¨åã«ããæ°ãã¸ãã¯ç¨ã®ã³ã¼ãã«ç½®æãã¦ããã ãã ãã§ãã®ä½æ¥ã¯å®äºã§ãã
æ§ã¤ã³ããã¯ã¹ã¸ã®ä¿ååæ¢ããã³åé¤
å®å ¨ã«æ§ã¢ããªã±ã¼ã·ã§ã³ãåæ¢ããå¾ã¯æ§ã¤ã³ããã¯ã¹ã¸ã®ä¿ååæ¢ãããã³ãã¤ã³ããã¯ã¹ã®åé¤ãè¡ãã¾ãã
èªåçã«åé¤ããããããªä»çµã¿ã«ãã¦ããã®ãéç¨ã³ã¹ããåæ¸ããããã«è¯ãææ³ã ã¨æããã¾ãã
ã¦ã¼ã¶ã¼æ¤ç´¢ã®ä¾ã«ããã¦ã¯ãUser.repositories_to_save
ã«è©²å½ããªããã®ãdeployæã«åé¤ãã¦ãã¾ãç¨åº¦ã®ã³ã¼ãã§ãåé¡ãªããããå®å
¨ãæããªããåé¤ã«ã¤ãã¦ã¯ãã°ããæ¾ç½®ãã¦ãè¯ãã§ããããQAãè¡ãåæã§ããã°æ§ã¤ã³ããã¯ã¹ã¸ã®ä¿åãåæ¢ããã¿ã¤ãã³ã°ã§ãdeployæã«åé¤ãã¦ãã¾ãæ¹ããã°ã®åç¾æ§ãé«ãã®ã§ããããã§ãã
以ä¸ã®æé ã«ãã£ã¦ãElasticsearchã®Indexãæ¬å½ã®æå³ã§ç¡åæ¢åæ§ç¯ãããã¨ãã§ãã¾ããã
ã¦ã¼ã¶ã¼æ¤ç´¢ã®ä¾ã§è¨ãã°ãæ°indexã¸ã®ä¿åãéå§ããã¿ã¤ãã³ã°ã¨ãæ°indexã¸åãæ¿ããè¡ãã¿ã¤ãã³ã°ã§ã®é½å2åã®deployãå¿ è¦ã«ãªãã¾ããããã¸ãã¯ã¨indexã¯ããããã®Repositoryå é¨ã«éãè¾¼ããããéçºå¹çãããé«ãã¦ãããã¨ãå¯è½ã ã¨æãã¾ãã
ã¾ã¨ã
æ¬è¨äºã§ã¯ãElasticsearchã®ã¤ã³ããã¯ã¹ãç¡åæ¢åæ§ç¯ããããã®ææ³ãç´¹ä»ãã¾ããã ã¢ããªã±ã¼ã·ã§ã³ã¬ã¤ã¤ã¼ããããã¤ã®ããã¼ã¾ã§çµ¡ããææ³ã«ã¯ãªãã¾ãããéçºã»éç¨ã®ã©ã¡ãã®é¢ãããé©ãã¦ããææ³ã ã¨èãã¦ãã¾ãã
Elasticsearchã¯ã¾ã ã¾ã åå¼·ä¸ãªã®ã§ãããé©åãªææ³ãªã©ãããã°æ¯éæãã¦ãã ããã
ã¨ãããã¨ã§ã Elastic stack (Elasticsearch) Advent Calendar 2017 ã®2æ¥ç®ã§ããã
次㯠st_1tãã ã® ãKibanaã®ãã³ãºãªã³çãªãã®ãã«ãªãã¾ãï¼ã楽ãã¿ã«ï¼