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
アルとAlgoliaと私 / alu_algolia
Search
Hikaru Tooyama
May 14, 2019
Business
8
2.3k
アルとAlgoliaと私 / alu_algolia
2019-05-14 Algolia Community Party in Tokyo
Hikaru Tooyama
May 14, 2019
Tweet
Share
More Decks by Hikaru Tooyama
See All by Hikaru Tooyama
Firestore東京リージョン利用に伴う Firebaseプロジェクト移行手順 / alu-firestore #アル
vexus2
8
2.5k
Firestoreを本番運用して得た知見と事件簿 / manga-village
vexus2
6
2.5k
エンジニア向けサービスを提供するチームでの開発環境改善
vexus2
1
1.3k
Other Decks in Business
See All in Business
Mercari-Fact-book_jp
mercari_inc
3
150k
UIL広島駅前 利用検討者への事業所紹介
ymtyhka7o4o8
0
250
enechain company deck
enechain
PRO
8
94k
Theoria technologies:About Us
theoriatec2024
1
5k
Japan Open Chain White Paper
gugroup
0
260
ストーリーテリングでチームに”熱"を伝える🔥
inagakikay
1
10k
(16枚)組織と集団の違いとは? 組織の「3要素」とは?
nyattx
PRO
3
2.1k
Works Human Intelligence
whisaiyo
1
79k
ダイナミックプラス株式会社 CompanyDeck20241201
plus0601
0
210
【エンジニア採用】BuySell Technologies会社説明資料
buyselltechnologies
2
55k
コーポレートストーリー(新規投資家様向け会社説明資料)
gatechnologies
1
9.5k
CData 製品を使って不動産API を可視化!実際に注文住宅を買ってみるまでの話
cdataj
2
150
Featured
See All Featured
Bash Introduction
62gerente
608
210k
Being A Developer After 40
akosma
87
590k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
Writing Fast Ruby
sferik
628
61k
A Tale of Four Properties
chriscoyier
157
23k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
The Cost Of JavaScript in 2023
addyosmani
45
7k
Code Review Best Practice
trishagee
65
17k
How to Think Like a Performance Engineer
csswizardry
22
1.2k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
48
2.2k
Faster Mobile Websites
deanohume
305
30k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
2
290
Transcript
1 ΞϧͱAlgoliaͱࢲ Ξϧגࣜձࣾɹԕࢁߊ !WFYVT
2 ࣗݾհ - Ξϧגࣜձࣾ ԕࢁߊ (@vexus2) - ݱ৬Ͱ VP of
Product - גࣜձࣾStorm දऔక - ։ൃίϯαϧςΟϯάۀ(Firebaseͱ͔) - ݩʑBackend(Ruby/PHP)͕ͩ࠷ۙFrontendدΓ - TypeScript / Vue / Nuxt / Firebase ͳͲ - Algoliaྺ16ϲ݄͘Β͍ - ݸਓαʔϏε࡞Δͱ͖ຖճAlgoliaʹσʔλΛೖΕΔͱ͜Ζ͔Β࢝ΊΔ ͘Β͍ͷAlgoliaґଘϢʔβ - झຯϚϯΨΛಡΉ͜ͱ - ࠓಡΜͰ໘ന͔ͬͨͷʮਖ਼ෆಈ࢈ʯʮఱࠃେຐڥʯʮΞΫλʔδϡʯʮONE OUTSʯʮϥϯ ΣΠͰসͬͯʯʮͦͷணͤସ͑ਓܗ࿀Λ͢ΔʯʮαπϦΫϧʔτʯʮͬ͠ΆͷʯʮΑฉ͍ͯ͘Εʯ ʮಓͷѱঁͨͪʯʮβɾϑΝϒϧʯʮ339ʯʮϰΟϯϥϯυɾαΨʯ
3 ࣗݾհ ແྉͰఏڙ͞Ε͍ͯΔອըΛूΊͨʮອըϏϨοδʯΛݸਓͰӡӦɻ ϐʔΫ࣌ͷաڈ30ؒͰ1060ສPV͕͋ΓɺͦͷޙΞϧϦϒϥϯυɻ Xxx ίϛϡχςΟ GoogleͰʮອըଜʯͰݕࡧ͢Δͱ1Ґʹ Yahoo!χϡʔεͷτοϓʹ(هࣄݩɿITmedia)
4 Ξϧͱʁ W
5 Ξϧʹ͍ͭͯ ΞϧϚϯΨϑΝϯͷͨΊʹɺϚϯΨΛൃݟͰ͖ΔศརͳαʔϏεΛఏڙ͢Δ ϚϯΨ୳͠ͷใαʔϏεͰ͢ɻ iOS/Web൛ΛͦΕͧΕఏڙதɻ(Android͏͙͢!)
6 Ұ෦ͷϚϯΨͷίϚ͕ߘɾӾཡ͕Ͱ͖·͢ɻ ֤ग़൛ࣾʹʹڐΛΒ͍ͬͯΔͷͰɺ ߹๏తͳίϚͷߘɾӾཡ͕Ͱ͖ΔαʔϏεͰ͢ɻ Ξϧʹ͍ͭͯ
7 શੈքதʹʮϚϯΨͷσʔλϕʔεʯͱ͍͏ͷ͕ଘࡏ͠ͳ͍ͷͰɺͱʹ͔͘େྔ ͳϚϯΨσʔλΛటष͘ूΊ͍ͯΔσʔλϕʔεͱͯ͠ͷଆ໘͋Γ·͢ɻ ʢΫϩʔϥʔɾೖߘɾਓྗͳͲʣ Ξϧʹ͍ͭͯ
8
9 FirestoreͱAlgoliaͷڞଘ W
10 Firestoreͷલఏ 1. FirestoreFirebaseͷυΩϡϝϯτࢦܗͷεέʔϥϒϧͳNoSQL 2. Queryׂ͕ͱශऑ - `<` >` `==`
`>=` `<=` ͑Δ - != (not equal) ͕ ͑ͳ͍ 3. limit, offsetͷΑ͏ͳ͜ͱ͕Ͱ͖ͳ͍(startAfter, startAt)ͷͰɺ ϖʔδωʔγϣϯͰͷpage=2ͷΑ͏ͳURLͷߏங͕ࠔ
11 Firestoreͷલఏ 4. औಘܶతʹ͘ͳ͍ɻ ࣮ߦڥ ॳճ 2ճҎ߱ us-central 1݅औಘ 892.3ms
202.3ms 20݅औಘ(SubCollection) 864ms 260.8ms asia-northeast1 1݅औಘ 370.3ms 125.6ms 20݅औಘ(SubCollection) 461.3ms 156.4ms ࢼߦճ100ճఔͷ؆қతͳϕϯνϚʔΫͰͷฏۉɻ ࣮ߦωοτϫʔΫڥͳͲʹΑͬͯมΘΔ͕ࢀߟ·Ͱɻ
12 Firestoreͱͷ͍͚
13 Firestore or Algolia? - ͋͘·Ͱσʔλϕʔεͱͯ͠Firestore͕Ϛελ - UniqueͳIDΛࢦఆͯ͠Ұҙʹऔͬͯ͜ΕΔ߹ʹFirestore - ୯ҰϑΟʔϧυͰͷSortQueryͰऔͬͯ͜ΕΔ߹ʹFirestore
- ෳࡶͳQuery݅ಛघͳSort݅(offsetͱؚ͔Ή)ɺPaginationΛؚΉ ߹ʹAlgolia - (Web൛ͳͲͰ)σʔλऔಘͷΛٻΊΔͱ͖ʹAlgolia
14 Ͳ͏͍͏σʔλΛAlgoliaʹ ͚ͬΔ͔
15 σʔλొʹ͍ͭͯ - AlgoliaݕࡧͱผͰϨίʔυͰͷ՝ۚ͋ΔͷͰʮݕࡧʹඞཁͳ࠷ খݶͷςʔϒϧʯͷΈొ - λΠϛϯάCloud Functions(Firebase)ͰFirestoreͷߋ৽τϦΨʔͷؔ Ͱɺߋ৽͞ΕͨσʔλΛAlgoliaʹొ͍ͯ͠Δ -
σʔλෆ߹͕ΠϠͳͷͰɺجຊతʹFirestoreͱಉ͡σʔλΛAlgolia ଆʹίϐʔ͢Δ
16 Algoliaͷخ͍͠ͱ͜Ζ W
17 خ͍͠ͱ͜Ζ: ͱʹ͔͍͘ - ͱʹ͔͘Response͕͍ɻΘ͚͕Θ͔Βͳ͍͘Β͍ʹɻ - 1୯ҐͷMonitoring reportݟͯɺaverage 1ms /
99th percentile 3ms ͱ͔͕βϥʹ͋Δ - աڈ1ͰҰ൪͔ͬͨͷ͕ average5ms / 99th percentile 16ms
18 خ͍͠ͱ͜Ζ: ݕࡧΦϓγϣϯ͕๛ - શҰகɺશจҰகͳͲͷݕࡧΦϓγϣϯ͕๛ͳͷͰʮHITݮΒͯ͠ Ͱਫ਼ͷߴ͍ݕࡧαδΣετʯͷΑ͏ͳ͜ͱ͕ϩδοΫଆͰௐ͢͠ ͍ - `matchLevel` ͱ͍͏ύϥϝʔλ͕ฦ͞ΕΔͷͰશҰகͷ߹͍Λஅ
Ͱ͖Δ - ʮDEATH NOTE (େ͙ͭΈɾখാ݈)ʯͷஶऀؔ࿈࡞ͱͯ͠ҎԼͷΑ͏ ͳ੍ޚָ͕ʹͰ͖Δ - ʮόΫϚϯ(େ͙ͭΈɾখാ݈)ʯදࣔ͢Δ - ʮϓϥνφΤϯυ(େ͙ͭΈɾখാ݈)ʯදࣔ͢Δ - ʮώΧϧͷޟ(΄ͬͨΏΈɾখാ݈)ʯදࣔ͠ͳ͍ - ʢදࣔ͢Δɺͱ͍͏Φϓγϣϯ༰қʹͰ͖Δʣ
19 خ͍͠ͱ͜Ζ: Web্Ͱ΄ͱΜͲΧελϚΠζͰ͖Δ - ݕࡧରͷΧϥϜ໊ɺrank͚ɺσϑΥϧτιʔτɺtypoܥͷڐ༰ൣғɺ Synonym(ಉٛޠ)ɺ۠Γจࣈઃఆɺϖʔδωʔγϣϯઃఆɺresponse ϑΟʔϧυઃఆɺetc… ͕Web্͔ΒઃఆͰ͖Δ
20 خ͍͠ͱ͜Ζ: ͍͍ײ͡ͷϨϙʔτ͕σϑΥϧτͰऔΕΔ - ຖͷݕࡧ No Result Rate, ্Ґݕࡧ No
Result Search ͷ݁ՌͳͲ ͕Index୯ҐͰࣗಈతʹAnalyticsʹೖ͍ͬͯΔɻ - Ξϧͷ߹ʮݕࡧͰHIT͠ͳ͔ͬͨϚϯΨʯͷ্ҐΫΤϦΛݩʹσʔλͷ ֦ॆͳͲͷ؍Ͱ͓͏ͱ͍ͯ͠Δ
21 AlgoliaͷͭΒ͍ͱ͜Ζ W
22 ͭΒ͍ͱ͜Ζ: ຊޠදهΏΕ͕བྷΉͷݸผରԠ - ຊޠͷΏΒ͗ͦ͜·ͰNo CustomizeͰڧ͘ͳ͍ͷͰɺ SynonymΛઃఆ͢Δඞཁ͕͋Δ - ONE PIECEΛʮϫϯϐʔεʯʮΘΜͽʔ͢ʯʮƂƃűƅʯʮONEPIECEʯ
ʮϫϯͽʯΈ͍ͨʹදهΏΕ͕େ͖͍ͱσϑΥϧτͷঢ়ଶͰతͷ ͷ͕HIT͠ͳ͍ - ΞϧͰSynonymΘͣʹϚϯΨͷʮུশʯʮදهΏΕʯٵऩ༻ͷΧ ϥϜ(alias)Λผ్ఆٛͯ͠Algoliaଆʹಉظ͍ͤͯ͞Δɻ
23 ͭΒ͍ͱ͜Ζ: filterपΓ͕ෳࡶ - ORݕࡧANDݕࡧͳͲ݅Λࢦఆ͢ΔʹfilterΛ͏͜ͱʹͳΔ͕ɺएׯ Ϋη͕͋ͬͯ࠷ॳ͔ΓͮΒ͍ɻ - ݅(filter)Λࢦఆ͢Δ߹ʹࣄલʹ Facet(attributesForFaceting)Λઃఆ ͢Δඞཁ͕͋Δ
- AND OR filtersͷதͰϕλͰॻ͘ඞཁ͕͋ΔɻएׯՄಡੑѱ͍ɻ - Boolean ܕ ΛFilter݅ʹೖΕΔͱ͖ʹ true/false Ͱͳ͘ 1/0 Ͱ͢ ඞཁ͕͋Δ
24 ͭΒ͍ͱ͜Ζ: Φϓγϣϯܥ͕߲͕ଟ͍ - QueryपΓΦϓγϣϯ͕๛ʹ͋ΔͷͰɺͰ͖Δ͜ͱΛશ෦Ѳ͢Δͷ͕ େมɾɾɾ - prefixType? advancedSyntax? optionalWords?
ͳʹͦΕʁঢ়ଶʹͳΔ - ෳͷΦϓγϣϯઃఆͨ͠ͱ͖ʹͲ͏͍͏݁ՌʹͳΔͷ͔ʁ͕͛Δલ ʹ૾͠ʹ͍͘͜ͱ͕ଟ͍ɻͷͰɺͻͨ͢Βࢼ͢͜ͱ͕ଟ͍ɻ - ͱʹ͔͘ࡶʹσʔλΛಥͬࠐΜͰऔಘ͢Δ͚ͩͳΒ؆୯ɻෳࡶͳ͜ͱ Ζ͏ͱ͢ΔͱυΩϡϝϯτΛख़ಡ͢ΕେମͳΜͱ͔ͳΔɻ
25 ͭΒ͍ͱ͜Ζ: Ϣʔβ͝ͱͷηΩϡΞͳσʔλ - جຊతʹશϨίʔυ͕ݕࡧରʹͳΔͷͰɺྫ͑ʮϢʔβ͝ͱͷߪೖ ཤྺʯͳͲଞऀͷݕࡧ݁Ռʹදࣔͨ͘͠ͳ͍ͷѻ͍ʹ͍͘ - Solutionͱͯ͠ʮࣗͷߪೖͨ͠ͷ͔͠ݟ͑ͳ͍(=ৗʹࣗͷuserIdͰ ϑΟϧλ)ʯݕࡧʹͳΔAlgoliaͷAPI_KEYΛϢʔβ͝ͱʹൃߦ͢ΔॲཧΛ༻ ҙͯ͠ɺϢʔβ͝ͱʹ֤ࣗͷΩʔͰݕࡧ͢ΔΑ͏ʹ͢ΕՄೳ
- ॲཧ͕͔ͳΓࡶʹͳΔ͠API_KEYͷऔΓճ͠Ͱ࣌ؒऔΒΕΔͷͰ Algoliaͷ͕٘ਜ਼ʹͳΔͷͰɺ͋·Γϕλʔͳײ͡͠ͳ͍ https://firebase.google.com/docs/firestore/solutions/search?hl=ja
26 ·ͱΊ W
27 ·ͱΊ - ͍ɾՁ֨ʢ͔Β͑Δʣɾߴػೳͱࡾഥࢠἧ͍ͬͯΔɻݸਓنͰ શવ͑Δஈଳʢͱ͍͏͔Freeϓϥϯ͋ΔʣͳͷͰϢʔβɾγεςϜ Θͣݕࡧͱ͍͏ߦҝΛߦ͏αʔϏεͰ͋ΕΘͳ͍ཧ༝ͳ͍ɻ - Algolia͍͔Βͦ͜ґଘੑ͕ߴ͍αʔϏεͳͷͰɺͲΜͲΜϨίʔυ ೖΕͯΨϯΨϯݕࡧ͢Δͱ͓ஈͦͦ͜͜ߴ͘ͳΓ͕ͪɻ͝ར༻ܭը తʹ
28