Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
motemote-data-science-2
Search
kur0cky
August 01, 2020
Technology
2
610
motemote-data-science-2
ネタですが,Rからelasticsearchを使ったり,elasticsearchの便利な機能を一部紹介しています笑
kur0cky
August 01, 2020
Tweet
Share
More Decks by kur0cky
See All by kur0cky
The bootstrapping method for everyone
kur0cky
3
930
音楽理論と方向統計学の初歩/introduction of circular statistics and musicology
kur0cky
4
1.8k
NLP introduction in R 1
kur0cky
0
72
tidyverse tutorial 2
kur0cky
1
55
tidyverse tutorial 1
kur0cky
1
67
rating_introduction
kur0cky
1
830
motemote data science 1
kur0cky
1
520
Other Decks in Technology
See All in Technology
顧客が本当に必要だったもの - パフォーマンス改善編 / Make what is needed
soudai
16
3.5k
Overview of file type identifiers
ange
0
200
Mackerelが取り組むオブザーバビリティ - Mackerel Tech Day
mackerelio
0
300
AWS SAW(AWS Support Automation Workflows)をもっと広めたい
kazzpapa3
2
170
いまからでも遅くない!コンテナでWebアプリを動かしてみよう入門(2-2)WebAPIハンズオン
nomu
0
150
CI/CDやテスト自動化の開発プロジェクトへの適用
megascus
2
400
6年の歴史×ペタバイト級のデータ基盤のチームを一体化する開発スタイル
plaidtech
PRO
4
110
Data Migration on Rails
ohbarye
6
3.4k
ActiveRecord SQLインジェクションクイズ (Rails 7.1.3.4)
kozy4324
9
2k
AIを使って小説を書こう!【2024/10/25講演資料】
kamomeashizawa
0
160
ZOZOのデータマネジメントの取り組み:これまでとこれから / ZOZO's Data Management Initiatives
takagiyudai
0
550
Databricksで構築する初めての複合AIシステム - ML15min
taka_aki
2
1.3k
Featured
See All Featured
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
328
21k
Speed Design
sergeychernyshev
24
560
Keith and Marios Guide to Fast Websites
keithpitt
408
22k
What's in a price? How to price your products and services
michaelherold
243
11k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
27
4.1k
Fashionably flexible responsive web design (full day workshop)
malarkey
404
65k
The Language of Interfaces
destraynor
154
24k
Agile that works and the tools we love
rasmusluckow
327
21k
The Power of CSS Pseudo Elements
geoffreycrofte
72
5.3k
Docker and Python
trallard
40
3k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
126
18k
Thoughts on Productivity
jonyablonski
67
4.3k
Transcript
σʔλͰʮϞςʯΛIBDLͤΑ BU5PLZP3 LVSDLZ dσΟφʔฤd
ࣗݾհ w 5XJUUFSɿ!LVSDLZ@Z w ॴଐɿ໊ཧͷIPHFIPHFʢϲ݄ʣ w झຯɿԻָɼөըɼ͓ञɼλΠϐϯάɼFUD w ΈɿϞς͍ͨ 2
લճdөըσʔτฤd w POFUPPOFͳөըσʔτମݧΛఏڙ͢ΔͨΊʹɼࣗવͳձͷத͔ΒϨ ϏϡʔΛਪఆ͢Δ͜ͱΛతͱͨ͠ɽ w ͦͷͨΊʹɼөըυϝΠϯઐ༻ͷۃੑࣙॻΛ࡞͠ɼϨίϝϯυʹ׆༻ 3 https://speakerdeck.com/kur0cky/motemote-data-science-1
өըΛݟͯऴΘΓͰྑ͔ͬͨͷͩΖ͏͔
࣮͕ޠ͍ͬͯΔ
Կ͕͍͚ͳ͔ͬͨͷ͔
ࠗ׆αΠτʹΑΔͱ өըͷ༨ӆΛָ͠ΜͩΓɺөըͱ͍͏ڞ௨ͷͷձ͔Β૬खͷঁੑʹ͍ͭͯ͞Β ʹΕͨΓͱɺөըͷޙઈͷίϛϡχέʔγϣϯͷػձͱͳΓ·͢ɻ͜ͷνϟϯε Λ͍͔ͨ͢Ίʹɺөըͷޙʹ͝൧͓ͳͲͷ༧ఆΛೖΕ·͠ΐ͏ɻ ภݟʹ·ΈΕ͍ͯΔ͕ɼ͍ͬͨΜ͜ΕΛ৴͡Δɽ
POFUPPOFͳөը͚ͩͰμϝ ͦͷޙͷձ͕ॏཁ
ϩʔϧϓϨΠϯά 9 ͓͠Ζ͔ͬͨͶʂʂ దʹೖͬͪΌ͓͏͔ ͜Εതଧɽऑऀʹద͕Θ͔ΒΜ ͓͍͍͠ΠλϦΞϯ༧͓͍ͯͨ͠Μͩʂʂ ༻ҙप౸͗ͯ͢ॏ͍͠ɼ͓ෲ͕ݮͬͯͳ͍͔͠Εͳ͍ ͳʹ͔৯ͳ͕ΒΖ͏ʂ গ͠า͍ͯɼྑ͛͞ͳͱ͜Ζ୳ͦ͞͏͔ ૬खͷੑ֨ॴʹେ͖͘ґଘɽา͖͗͢/(ɽϦεΩʔ
ͦͷͰαΫͬͱݕࡧͰ͖Δ ΞϓϦ͕ॏཁ
3ͱFMBTUJDTFBSDI BU5PLZP3 LVSDLZ
w શจݕࡧγεςϜ w ಛɿ w ߴɽࢄܕͰεέʔϥϒϧɽΦʔϓϯιʔεɽ3&45"1*ɽ +40/ʹΑΔॊೈͳσʔλߏɽείΞϦϯάͷΧελϚΠζɽ 12 ՄࢹԽɾੳ ݕࡧ
σʔλऩू
Πϯετʔϧɾىಈ w .BDͷ߹ brew tap elastic/tap brew install elastic/tap/elasticsearch-full brew
install elastic/tap/kibana-full brew install elastic/tap/logstash-full brew install elastic/tap/metricbeat-full elasticsearch & kibana & w IUUQMPDBMIPTUͰใ͕ฦͬͯ͘Εىಈޭ w ,JCBOB IUUQMPDBMIPTU ͷ$POTPMFΛ͏ͱ৭ʑࢼ͍͢͠ 13 ଞͷ04ɿIUUQTXXXFMBTUJDDPHVJEFFOFMBTUJDTUBDLDVSSFOUJOTUBMMJOHFMBTUJDTUBDLIUNM
جຊ༻ޠ w ΠϯσοΫε w FMBTUJDTFBSDI͕ݕࡧɾղੳͷରͱ͢Δσʔλͷอଘઌ w υΩϡϝϯτλΠϓ w ΠϯσοΫεͷάϧʔϓ w
υΩϡϝϯτ w FMBTUJDTFBSDIʹอଘ͞Εͨσʔλ w ϑΟʔϧυ w υΩϡϝϯτʹؚ·ΕΔଐੑ 14 σʔλϕʔε ςʔϒϧ Ϩίʔυ ΧϥϜ 3%#Ͱ͍͏ͱɹɹ
؆୯ͳ͍ํ w +40/ͱ3&45"1*ͰઃఆɾΠϯσΩγϯάʢೖʣɾݕࡧͯ͢Λߦ͏ 15 • ݕࡧ GET index_name/_search { "query"
: { "match" : { "comment" : "σʔτ" } } } • ΠϯσΩγϯά PUT index_name/ { "name" : "ϥʔϝϯೋ", "genre" : "όʔɾμΠχϯά" } • ઃఆ PUT index_name/ { "settings" : { hogehoge }, "mappings" : { fugafuga } } ܗଶૉղੳશ֯ͷ౷ҰͳͲ ༷ʑͳઃఆΛهड़ ೖ͢Δσʔλ͕ͲͷΑ͏ͳ ϑΟʔϧυΛͪ͏Δͷ͔ɼͦͷܕهड़
3͔ΒFMBTUJDTFBSDIΛୟ͘ w FMBTUJDύοέʔδ͔Βୟ͘ɽ w σʔλϑϨʔϜΛΠϯσΩγϯάͰ͖Δɽ w શͯΛ3Ͱ͍݁ͤͨ͞ʂʂ w ΫΤϦɼϦετͰॻ͍ͯKTPOMJUFͰ+40/ʹ w
جຊͷૢ࡞ 1. conn <- connect(host="127.0.0.1", port=9200) 2. docs_bulk(conn, df, index) 3. Search(conn, index, body = <query>) 16
࣮ફ
త w өըσʔτײઓͰ͢Δ w ϩʔϧϓϨΠϯάͷ݁Ռɼ͍͔ͭ͘ͷཁ݅Λຬͨ͢ඞཁ͕͋Δ w ͦͷͷঢ়گʹ߹ΘͤͯαΫοͱܾΊΔ͜ͱ͕ॏཁ w جຊతʹ͋·Γา͔ͤͳ͍ w
Ͱ͖Δ͚࣭ͩͷྑ͍ళʹೖΔ 18
ͬͨ͜ͱ w ༻σʔλ w ौ୩ۙลͷϨετϥϯ݅ w ళ໊ɼδϟϯϧɼਓؾͷΫνίϛɼͦͷଞళฮใ 19 HFPDPEJOH"1* ݕࡧ6*
MFBqFUʹΑΔਤ %5ʹΑΔ៉ྷͳද ݱࡏͷऔಘ ݕࡧ εΫϨΠϐϯά
ཁ݅ͷୡ w LVSPNPKJQMVHJOʹΑΔલॲཧ w τʔΫϯԽɼશ֯౷ҰɼεςϛϯάɼFUD w σϑΥϧτͷείΞʢ#.ʣΛ͏ w ۙ͞ʹԠͨ͡ݮਰؔ͏ w
৯ϩάείΞ͏ 20 w ຊޠͷݕࡧ w ΫΤϦͱͷϚον w ͋·Γา͔ͤͳ͍ w ͍͍ళʹೖΔ https://www.elastic.co/guide/en/elasticsearch/plugins/current/analysis-kuromoji-analyzer.html
ڑʹԠͨ͡ݮਰؔ w ࠓճɼҢɾܦͦΕͧΕʹ ΨγΞϯΛ༻ w ଞʹɼࢦؔઢܗ͕͋Δ 21 https://www.elastic.co/guide/en/elasticsearch/reference/current/query- dsl-function-score-query.html
{ "query": { "function_score": { "query": { ී௨ͷΫΤϦ͜͜ʹॻ͘ }, "functions":
[ { "gauss": { "latitude": { "origin": [35.6591], "scale": [0.003] } } }, { "gauss": { "longitude": { "origin": [139.7003], "scale": [0.003] } } }, { "field_value_factor": { "field": ["score"], "factor": [3], "modifier": ["log"], "missing": [1] } } ], "score_mode": ["multiply"] } }, "size": [1000], "_source": ["name", "score", "genre", "tel_number"] } GVODUJPO@TDPSFʹΑΔείΞͷ౷߹ 22 Ңͷݮਰ ܦͷݮਰ ϑΟʔϧυͷ ͦͷͷΛ͏ ͜ΕΒͷֻ͚ࢉͰ ࠷ऴతͳείΞͱ͢Δ KTPOΈʹͯ͘͘ਃ͠༁ͳ͍Ͱ͢ɾɾɾ
σϞ
None
·ͱΊ w POFUPPOFөըσʔτମݧΛఏڙ͢ΔͨΊʹɼ૬खͷΈΛεϜʔζ ʹఆྔԽ͢Δ͚ͩͰμϝͩͬͨɽ w ʮөըσʔτײઓͰ͢Δʯͱ͍͏Ծઆͷͱɼྑ͍ళΛαΫͬͱ ݕࡧͰ͖ΔΞϓϦΛ࡞ͨ͠ɽ w ಛʹɼݱࡏҐஔ͔Βͷڑɾ৯ϩάͷείΞɾΫΤϦͱͷϚονΛ ߟྀͨ͠είΞϦϯάΛߦͬͨɽ
25 FMBTUJDTFBSDI͍͍ͧʂ ʢެࣜυΩϡϝϯτ͕ຊʹʣ
&OKPZ