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ྺ͸1೥6ϲ݄͘Β͍ - ݸਓαʔϏε࡞Δͱ͖͸ຖճ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. Firestore͸FirebaseͷυΩϡϝϯτࢦ޲ܗͷεέʔϥϒϧͳ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 - ୯ҰϑΟʔϧυͰͷSort΍QueryͰऔͬͯ͜ΕΔ৔߹ʹ͸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