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
kintoneを活用した緊急通行車両確認手続の迅速化
tokyo_metropolitan_gov_digital_hr
0
420
会社紹介資料
ldf_tech
1
330
culturebook_WeddingParkShip
weddingpark
0
570
メタバースを活用した観光PR
tokyo_metropolitan_gov_digital_hr
0
320
20241027.jjug_ccc_creditsaison.pdf
lalha
4
2.5k
Company deck
tricera
0
500
アルプ株式会社/会社紹介資料
alpinc
0
470
5 Things Every L&D Pro Should Steal From Marketing
trainlikeamarketer
0
420
もしドラッカーがアジャイルコーチになったら / If Drucker Were an Agile Coach
fkino
2
410
la belle vie Inc. Company Introduction for Merchandiser
recruiting
0
2k
Ampersand Company Profile
cuebicventures
PRO
0
240
merpay-overview_en
mercari_inc
1
17k
Featured
See All Featured
Happy Clients
brianwarren
98
6.7k
BBQ
matthewcrist
85
9.3k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
506
140k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
[RailsConf 2023] Rails as a piece of cake
palkan
52
4.9k
What's in a price? How to price your products and services
michaelherold
243
12k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
27
840
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
The Cult of Friendly URLs
andyhume
78
6k
RailsConf 2023
tenderlove
29
900
Imperfection Machines: The Place of Print at Facebook
scottboms
265
13k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
31
2.7k
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