Upgrade to Pro — share decks privately, control downloads, hide ads and more …

アルとAlgoliaと私 / alu_algolia

アルとAlgoliaと私 / alu_algolia

2019-05-14 Algolia Community Party in Tokyo

Hikaru Tooyama

May 14, 2019
Tweet

More Decks by Hikaru Tooyama

Other Decks in Business

Transcript

  1. 2 ࣗݾ঺հ - Ξϧגࣜձࣾ ԕࢁߊ (@vexus2) - ݱ৬Ͱ͸ VP of

    Product - גࣜձࣾStorm ୅දऔక໾ - ։ൃίϯαϧςΟϯάۀ(Firebaseͱ͔) - ݩʑBackend(Ruby/PHP)͕ͩ࠷ۙ͸FrontendدΓ - TypeScript / Vue / Nuxt / Firebase ͳͲ - Algoliaྺ͸1೥6ϲ݄͘Β͍ - ݸਓαʔϏε࡞Δͱ͖͸ຖճAlgoliaʹσʔλΛೖΕΔͱ͜Ζ͔Β࢝ΊΔ ͘Β͍ͷAlgoliaґଘ঱Ϣʔβ - झຯ͸ϚϯΨΛಡΉ͜ͱ - ࠓ೥ಡΜͰ໘ന͔ͬͨ΋ͷ͸ʮਖ਼௚ෆಈ࢈ʯʮఱࠃେຐڥʯʮΞΫλʔδϡʯʮONE OUTSʯʮϥϯ ΢ΣΠͰসͬͯʯʮͦͷணͤସ͑ਓܗ͸࿀Λ͢ΔʯʮαπϦΫϧʔτʯʮͬ͠Άͷ੠ʯʮ೾Αฉ͍ͯ͘Εʯ ʮ࿡ಓͷѱঁͨͪʯʮβɾϑΝϒϧʯʮ௄໾339೥ʯʮϰΟϯϥϯυɾαΨʯ
  2. 8

  3. 10 Firestoreͷલఏ 1. Firestore͸FirebaseͷυΩϡϝϯτࢦ޲ܗͷεέʔϥϒϧͳNoSQL 2. Queryׂ͕ͱශऑ - `<` >` `==`

    `>=` `<=` ͸࢖͑Δ - != (not equal) ͕ ࢖͑ͳ͍ 3. limit, offsetͷΑ͏ͳ͜ͱ͕Ͱ͖ͳ͍(startAfter, startAt)ͷͰɺ
 ϖʔδωʔγϣϯͰͷpage=2ͷΑ͏ͳURLͷߏங͕ࠔ೉
  4. 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ճఔ౓ͷ؆қతͳϕϯνϚʔΫͰͷฏۉ஋ɻ ࣮ߦωοτϫʔΫ؀ڥͳͲʹΑͬͯมΘΔ͕ࢀߟ·Ͱɻ
  5. 13 Firestore or Algolia? - ͋͘·Ͱσʔλϕʔεͱͯ͠͸Firestore͕Ϛελ - UniqueͳIDΛࢦఆͯ͠Ұҙʹऔͬͯ͜ΕΔ৔߹ʹ͸Firestore - ୯ҰϑΟʔϧυͰͷSort΍QueryͰऔͬͯ͜ΕΔ৔߹ʹ͸Firestore

    - ෳࡶͳQuery৚݅΍ಛघͳSort৚݅(offsetͱ͔΋ؚΉ)ɺPaginationΛؚΉ৔ ߹ʹ͸Algolia - (Web൛ͳͲͰ)σʔλऔಘͷ଎౓ΛٻΊΔͱ͖ʹ͸Algolia
  6. 17 خ͍͠ͱ͜Ζ: ͱʹ͔͘଎͍ - ͱʹ͔͘Response͕଎͍ɻΘ͚͕Θ͔Βͳ͍͘Β͍ʹɻ - 1೥୯ҐͷMonitoring reportݟͯ΋ɺaverage 1ms /

    99th percentile 3ms ͱ͔͕βϥʹ͋Δ - աڈ1೥ͰҰ൪஗͔ͬͨͷ͕ average5ms / 99th percentile 16ms
  7. 18 خ͍͠ͱ͜Ζ: ݕࡧΦϓγϣϯ͕๛෋ - ׬શҰகɺશจҰகͳͲͷݕࡧΦϓγϣϯ͕๛෋ͳͷͰʮHIT਺͸ݮΒͯ͠ Ͱ΋ਫ਼౓ͷߴ͍ݕࡧαδΣετʯͷΑ͏ͳ͜ͱ͕ϩδοΫଆͰௐ੔͠΍͢ ͍ - `matchLevel` ͱ͍͏ύϥϝʔλ͕ฦ͞ΕΔͷͰ׬શҰகͷ౓߹͍Λ൑அ

    Ͱ͖Δ - ʮDEATH NOTE (େ৔͙ͭΈɾখാ݈)ʯͷஶऀؔ࿈࡞඼ͱͯ͠ҎԼͷΑ͏ ͳ੍ޚָ͕ʹͰ͖Δ - ʮόΫϚϯ(େ৔͙ͭΈɾখാ݈)ʯ͸දࣔ͢Δ - ʮϓϥνφΤϯυ(େ৔͙ͭΈɾখാ݈)ʯ͸දࣔ͢Δ - ʮώΧϧͷޟ(΄ͬͨΏΈɾখാ݈)ʯ͸දࣔ͠ͳ͍ - ʢදࣔ͢Δɺͱ͍͏Φϓγϣϯ΋༰қʹͰ͖Δʣ
  8. 20 خ͍͠ͱ͜Ζ: ͍͍ײ͡ͷϨϙʔτ͕σϑΥϧτͰऔΕΔ - ೔ຖͷݕࡧ਺΍ No Result Rate, ্Ґݕࡧ΍ No

    Result Search ͷ݁ՌͳͲ ͕Index୯ҐͰࣗಈతʹAnalyticsʹೖ͍ͬͯΔɻ - Ξϧͷ৔߹͸ʮݕࡧͰHIT͠ͳ͔ͬͨϚϯΨʯͷ্ҐΫΤϦΛݩʹσʔλͷ ֦ॆͳͲͷ؍఺Ͱ࢖͓͏ͱ͍ͯ͠Δ
  9. 22 ͭΒ͍ͱ͜Ζ: ೔ຊޠදهΏΕ͕བྷΉ΋ͷ͸ݸผରԠ - ೔ຊޠͷΏΒ͗͸ͦ͜·ͰNo CustomizeͰ͸ڧ͘͸ͳ͍ͷͰɺ౎౓ SynonymΛઃఆ͢Δඞཁ͕͋Δ - ONE PIECEΛʮϫϯϐʔεʯʮΘΜͽʔ͢ʯʮƂƃűƅʯʮONEPIECEʯ

    ʮϫϯͽʯΈ͍ͨʹදهΏΕ͕େ͖͍ͱσϑΥϧτͷঢ়ଶͰ͸໨తͷ΋ ͷ͕HIT͠ͳ͍ - ΞϧͰ͸Synonym͸࢖ΘͣʹϚϯΨͷʮུশʯʮදهΏΕʯٵऩ༻ͷΧ ϥϜ(alias)Λผ్ఆٛͯ͠Algoliaଆʹ΋ಉظ͍ͤͯ͞Δɻ
  10. 23 ͭΒ͍ͱ͜Ζ: filterपΓ͕ෳࡶ - ORݕࡧ΍ANDݕࡧͳͲ৚݅Λࢦఆ͢Δʹ͸filterΛ࢖͏͜ͱʹͳΔ͕ɺएׯ Ϋη͕͋ͬͯ࠷ॳ͸෼͔ΓͮΒ͍ɻ - ৚݅(filter)Λࢦఆ͢Δ৔߹ʹ͸ࣄલʹ Facet(attributesForFaceting)Λઃఆ ͢Δඞཁ͕͋Δ

    - AND ΍ OR ͸filtersͷதͰϕλͰॻ͘ඞཁ͕͋ΔɻएׯՄಡੑ͸ѱ͍ɻ - Boolean ܕ ΛFilter৚݅ʹೖΕΔͱ͖ʹ͸ true/false Ͱ͸ͳ͘ 1/0 Ͱ౉͢ ඞཁ͕͋Δ
  11. 24 ͭΒ͍ͱ͜Ζ: Φϓγϣϯܥ͕߲໨͕ଟ͍ - QueryपΓ΋Φϓγϣϯ͕๛෋ʹ͋ΔͷͰɺͰ͖Δ͜ͱΛશ෦೺Ѳ͢Δͷ͕ େมɾɾɾ - prefixType? advancedSyntax? optionalWords?

    ͳʹͦΕʁঢ়ଶʹͳΔ - ෳ਺ͷΦϓγϣϯઃఆͨ͠ͱ͖ʹͲ͏͍͏݁ՌʹͳΔͷ͔ʁ͕౤͛Δલ ʹ૝૾͠ʹ͍͘͜ͱ͕ଟ͍ɻͷͰɺͻͨ͢Βࢼ͢͜ͱ͕ଟ͍ɻ - ͱʹ͔͘ࡶʹσʔλΛಥͬࠐΜͰऔಘ͢Δ͚ͩͳΒ௒؆୯ɻෳࡶͳ͜ͱ΍ Ζ͏ͱ͢ΔͱυΩϡϝϯτΛख़ಡ͢Ε͹େମͳΜͱ͔ͳΔɻ
  12. 28