アルとAlgoliaと私 / alu_algolia
by
Hikaru Tooyama
Link
Embed
Share
Beginning
This slide
Copy link URL
Copy link URL
Copy iframe embed code
Copy iframe embed code
Copy javascript embed code
Copy javascript embed code
Share
Tweet
Share
Tweet
Slide 1
Slide 1 text
1 ΞϧͱAlgoliaͱࢲ Ξϧגࣜձࣾɹԕࢁߊ !WFYVT
Slide 2
Slide 2 text
2 ࣗݾհ - Ξϧגࣜձࣾ ԕࢁߊ (@vexus2) - ݱ৬Ͱ VP of Product - גࣜձࣾStorm දऔక - ։ൃίϯαϧςΟϯάۀ(Firebaseͱ͔) - ݩʑBackend(Ruby/PHP)͕ͩ࠷ۙFrontendدΓ - TypeScript / Vue / Nuxt / Firebase ͳͲ - Algoliaྺ16ϲ݄͘Β͍ - ݸਓαʔϏε࡞Δͱ͖ຖճAlgoliaʹσʔλΛೖΕΔͱ͜Ζ͔Β࢝ΊΔ ͘Β͍ͷAlgoliaґଘϢʔβ - झຯϚϯΨΛಡΉ͜ͱ - ࠓಡΜͰ໘ന͔ͬͨͷʮਖ਼ෆಈ࢈ʯʮఱࠃେຐڥʯʮΞΫλʔδϡʯʮONE OUTSʯʮϥϯ ΣΠͰসͬͯʯʮͦͷணͤସ͑ਓܗ࿀Λ͢ΔʯʮαπϦΫϧʔτʯʮͬ͠ΆͷʯʮΑฉ͍ͯ͘Εʯ ʮಓͷѱঁͨͪʯʮβɾϑΝϒϧʯʮ339ʯʮϰΟϯϥϯυɾαΨʯ
Slide 3
Slide 3 text
3 ࣗݾհ ແྉͰఏڙ͞Ε͍ͯΔອըΛूΊͨʮອըϏϨοδʯΛݸਓͰӡӦɻ ϐʔΫ࣌ͷաڈ30ؒͰ1060ສPV͕͋ΓɺͦͷޙΞϧϦϒϥϯυɻ Xxx ίϛϡχςΟ GoogleͰʮອըଜʯͰݕࡧ͢Δͱ1Ґʹ Yahoo!χϡʔεͷτοϓʹ(هࣄݩɿITmedia)
Slide 4
Slide 4 text
4 Ξϧͱʁ W
Slide 5
Slide 5 text
5 Ξϧʹ͍ͭͯ ΞϧϚϯΨϑΝϯͷͨΊʹɺϚϯΨΛൃݟͰ͖ΔศརͳαʔϏεΛఏڙ͢Δ ϚϯΨ୳͠ͷใαʔϏεͰ͢ɻ iOS/Web൛ΛͦΕͧΕఏڙதɻ(Android͏͙͢!)
Slide 6
Slide 6 text
6 Ұ෦ͷϚϯΨͷίϚ͕ߘɾӾཡ͕Ͱ͖·͢ɻ ֤ग़൛ࣾʹʹڐΛΒ͍ͬͯΔͷͰɺ ߹๏తͳίϚͷߘɾӾཡ͕Ͱ͖ΔαʔϏεͰ͢ɻ Ξϧʹ͍ͭͯ
Slide 7
Slide 7 text
7 શੈքதʹʮϚϯΨͷσʔλϕʔεʯͱ͍͏ͷ͕ଘࡏ͠ͳ͍ͷͰɺͱʹ͔͘େྔ ͳϚϯΨσʔλΛటष͘ूΊ͍ͯΔσʔλϕʔεͱͯ͠ͷଆ໘͋Γ·͢ɻ ʢΫϩʔϥʔɾೖߘɾਓྗͳͲʣ Ξϧʹ͍ͭͯ
Slide 8
Slide 8 text
8
Slide 9
Slide 9 text
9 FirestoreͱAlgoliaͷڞଘ W
Slide 10
Slide 10 text
10 Firestoreͷલఏ 1. FirestoreFirebaseͷυΩϡϝϯτࢦܗͷεέʔϥϒϧͳNoSQL 2. Queryׂ͕ͱශऑ - `<` >` `==` `>=` `<=` ͑Δ - != (not equal) ͕ ͑ͳ͍ 3. limit, offsetͷΑ͏ͳ͜ͱ͕Ͱ͖ͳ͍(startAfter, startAt)ͷͰɺ ϖʔδωʔγϣϯͰͷpage=2ͷΑ͏ͳURLͷߏங͕ࠔ
Slide 11
Slide 11 text
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ճఔͷ؆қతͳϕϯνϚʔΫͰͷฏۉɻ ࣮ߦωοτϫʔΫڥͳͲʹΑͬͯมΘΔ͕ࢀߟ·Ͱɻ
Slide 12
Slide 12 text
12 Firestoreͱͷ͍͚
Slide 13
Slide 13 text
13 Firestore or Algolia? - ͋͘·Ͱσʔλϕʔεͱͯ͠Firestore͕Ϛελ - UniqueͳIDΛࢦఆͯ͠Ұҙʹऔͬͯ͜ΕΔ߹ʹFirestore - ୯ҰϑΟʔϧυͰͷSortQueryͰऔͬͯ͜ΕΔ߹ʹFirestore - ෳࡶͳQuery݅ಛघͳSort݅(offsetͱؚ͔Ή)ɺPaginationΛؚΉ ߹ʹAlgolia - (Web൛ͳͲͰ)σʔλऔಘͷΛٻΊΔͱ͖ʹAlgolia
Slide 14
Slide 14 text
14 Ͳ͏͍͏σʔλΛAlgoliaʹ ͚ͬΔ͔
Slide 15
Slide 15 text
15 σʔλొʹ͍ͭͯ - AlgoliaݕࡧͱผͰϨίʔυͰͷ՝ۚ͋ΔͷͰʮݕࡧʹඞཁͳ࠷ খݶͷςʔϒϧʯͷΈొ - λΠϛϯάCloud Functions(Firebase)ͰFirestoreͷߋ৽τϦΨʔͷؔ Ͱɺߋ৽͞ΕͨσʔλΛAlgoliaʹొ͍ͯ͠Δ - σʔλෆ߹͕ΠϠͳͷͰɺجຊతʹFirestoreͱಉ͡σʔλΛAlgolia ଆʹίϐʔ͢Δ
Slide 16
Slide 16 text
16 Algoliaͷخ͍͠ͱ͜Ζ W
Slide 17
Slide 17 text
17 خ͍͠ͱ͜Ζ: ͱʹ͔͍͘ - ͱʹ͔͘Response͕͍ɻΘ͚͕Θ͔Βͳ͍͘Β͍ʹɻ - 1୯ҐͷMonitoring reportݟͯɺaverage 1ms / 99th percentile 3ms ͱ͔͕βϥʹ͋Δ - աڈ1ͰҰ൪͔ͬͨͷ͕ average5ms / 99th percentile 16ms
Slide 18
Slide 18 text
18 خ͍͠ͱ͜Ζ: ݕࡧΦϓγϣϯ͕๛ - શҰகɺશจҰகͳͲͷݕࡧΦϓγϣϯ͕๛ͳͷͰʮHITݮΒͯ͠ Ͱਫ਼ͷߴ͍ݕࡧαδΣετʯͷΑ͏ͳ͜ͱ͕ϩδοΫଆͰௐ͢͠ ͍ - `matchLevel` ͱ͍͏ύϥϝʔλ͕ฦ͞ΕΔͷͰશҰகͷ߹͍Λஅ Ͱ͖Δ - ʮDEATH NOTE (େ͙ͭΈɾখാ݈)ʯͷஶऀؔ࿈࡞ͱͯ͠ҎԼͷΑ͏ ͳ੍ޚָ͕ʹͰ͖Δ - ʮόΫϚϯ(େ͙ͭΈɾখാ݈)ʯදࣔ͢Δ - ʮϓϥνφΤϯυ(େ͙ͭΈɾখാ݈)ʯදࣔ͢Δ - ʮώΧϧͷޟ(΄ͬͨΏΈɾখാ݈)ʯදࣔ͠ͳ͍ - ʢදࣔ͢Δɺͱ͍͏Φϓγϣϯ༰қʹͰ͖Δʣ
Slide 19
Slide 19 text
19 خ͍͠ͱ͜Ζ: Web্Ͱ΄ͱΜͲΧελϚΠζͰ͖Δ - ݕࡧରͷΧϥϜ໊ɺrank͚ɺσϑΥϧτιʔτɺtypoܥͷڐ༰ൣғɺ Synonym(ಉٛޠ)ɺ۠Γจࣈઃఆɺϖʔδωʔγϣϯઃఆɺresponse ϑΟʔϧυઃఆɺetc… ͕Web্͔ΒઃఆͰ͖Δ
Slide 20
Slide 20 text
20 خ͍͠ͱ͜Ζ: ͍͍ײ͡ͷϨϙʔτ͕σϑΥϧτͰऔΕΔ - ຖͷݕࡧ No Result Rate, ্Ґݕࡧ No Result Search ͷ݁ՌͳͲ ͕Index୯ҐͰࣗಈతʹAnalyticsʹೖ͍ͬͯΔɻ - Ξϧͷ߹ʮݕࡧͰHIT͠ͳ͔ͬͨϚϯΨʯͷ্ҐΫΤϦΛݩʹσʔλͷ ֦ॆͳͲͷ؍Ͱ͓͏ͱ͍ͯ͠Δ
Slide 21
Slide 21 text
21 AlgoliaͷͭΒ͍ͱ͜Ζ W
Slide 22
Slide 22 text
22 ͭΒ͍ͱ͜Ζ: ຊޠදهΏΕ͕བྷΉͷݸผରԠ - ຊޠͷΏΒ͗ͦ͜·ͰNo CustomizeͰڧ͘ͳ͍ͷͰɺ SynonymΛઃఆ͢Δඞཁ͕͋Δ - ONE PIECEΛʮϫϯϐʔεʯʮΘΜͽʔ͢ʯʮƂƃűƅʯʮONEPIECEʯ ʮϫϯͽʯΈ͍ͨʹදهΏΕ͕େ͖͍ͱσϑΥϧτͷঢ়ଶͰతͷ ͷ͕HIT͠ͳ͍ - ΞϧͰSynonymΘͣʹϚϯΨͷʮུশʯʮදهΏΕʯٵऩ༻ͷΧ ϥϜ(alias)Λผ్ఆٛͯ͠Algoliaଆʹಉظ͍ͤͯ͞Δɻ
Slide 23
Slide 23 text
23 ͭΒ͍ͱ͜Ζ: filterपΓ͕ෳࡶ - ORݕࡧANDݕࡧͳͲ݅Λࢦఆ͢ΔʹfilterΛ͏͜ͱʹͳΔ͕ɺएׯ Ϋη͕͋ͬͯ࠷ॳ͔ΓͮΒ͍ɻ - ݅(filter)Λࢦఆ͢Δ߹ʹࣄલʹ Facet(attributesForFaceting)Λઃఆ ͢Δඞཁ͕͋Δ - AND OR filtersͷதͰϕλͰॻ͘ඞཁ͕͋ΔɻएׯՄಡੑѱ͍ɻ - Boolean ܕ ΛFilter݅ʹೖΕΔͱ͖ʹ true/false Ͱͳ͘ 1/0 Ͱ͢ ඞཁ͕͋Δ
Slide 24
Slide 24 text
24 ͭΒ͍ͱ͜Ζ: Φϓγϣϯܥ͕߲͕ଟ͍ - QueryपΓΦϓγϣϯ͕๛ʹ͋ΔͷͰɺͰ͖Δ͜ͱΛશ෦Ѳ͢Δͷ͕ େมɾɾɾ - prefixType? advancedSyntax? optionalWords? ͳʹͦΕʁঢ়ଶʹͳΔ - ෳͷΦϓγϣϯઃఆͨ͠ͱ͖ʹͲ͏͍͏݁ՌʹͳΔͷ͔ʁ͕͛Δલ ʹ૾͠ʹ͍͘͜ͱ͕ଟ͍ɻͷͰɺͻͨ͢Βࢼ͢͜ͱ͕ଟ͍ɻ - ͱʹ͔͘ࡶʹσʔλΛಥͬࠐΜͰऔಘ͢Δ͚ͩͳΒ؆୯ɻෳࡶͳ͜ͱ Ζ͏ͱ͢ΔͱυΩϡϝϯτΛख़ಡ͢ΕେମͳΜͱ͔ͳΔɻ
Slide 25
Slide 25 text
25 ͭΒ͍ͱ͜Ζ: Ϣʔβ͝ͱͷηΩϡΞͳσʔλ - جຊతʹશϨίʔυ͕ݕࡧରʹͳΔͷͰɺྫ͑ʮϢʔβ͝ͱͷߪೖ ཤྺʯͳͲଞऀͷݕࡧ݁Ռʹදࣔͨ͘͠ͳ͍ͷѻ͍ʹ͍͘ - Solutionͱͯ͠ʮࣗͷߪೖͨ͠ͷ͔͠ݟ͑ͳ͍(=ৗʹࣗͷuserIdͰ ϑΟϧλ)ʯݕࡧʹͳΔAlgoliaͷAPI_KEYΛϢʔβ͝ͱʹൃߦ͢ΔॲཧΛ༻ ҙͯ͠ɺϢʔβ͝ͱʹ֤ࣗͷΩʔͰݕࡧ͢ΔΑ͏ʹ͢ΕՄೳ - ॲཧ͕͔ͳΓࡶʹͳΔ͠API_KEYͷऔΓճ͠Ͱ࣌ؒऔΒΕΔͷͰ Algoliaͷ͕٘ਜ਼ʹͳΔͷͰɺ͋·Γϕλʔͳײ͡͠ͳ͍ https://firebase.google.com/docs/firestore/solutions/search?hl=ja
Slide 26
Slide 26 text
26 ·ͱΊ W
Slide 27
Slide 27 text
27 ·ͱΊ - ͍ɾՁ֨ʢ͔Β͑Δʣɾߴػೳͱࡾഥࢠἧ͍ͬͯΔɻݸਓنͰ શવ͑Δஈଳʢͱ͍͏͔Freeϓϥϯ͋ΔʣͳͷͰϢʔβɾγεςϜ Θͣݕࡧͱ͍͏ߦҝΛߦ͏αʔϏεͰ͋ΕΘͳ͍ཧ༝ͳ͍ɻ - Algolia͍͔Βͦ͜ґଘੑ͕ߴ͍αʔϏεͳͷͰɺͲΜͲΜϨίʔυ ೖΕͯΨϯΨϯݕࡧ͢Δͱ͓ஈͦͦ͜͜ߴ͘ͳΓ͕ͪɻ͝ར༻ܭը తʹ
Slide 28
Slide 28 text
28