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

Developers.IO 2016 C-2 「Elasticsearchで自由自在に検索・分析できるようになるためのヒント」

Kunihiko Kido
February 22, 2016

Developers.IO 2016 C-2 「Elasticsearchで自由自在に検索・分析できるようになるためのヒント」

Kunihiko Kido

February 22, 2016
Tweet

More Decks by Kunihiko Kido

Other Decks in Technology

Transcript

  1. %FWFMPQFST*0
    $
    Ϋϥεϝιουגࣜձࣾɹ໦ށࠃ඙
    ⡥$MBTTNFUIPE *OD
    ೥݄೔
    &MBTUJDTFBSDIͰɺ
    ࣗ༝ࣗࡏʹݕࡧɾ෼ੳ
    Ͱ͖ΔΑ͏ʹͳΔͨΊͷώϯτ

    View full-size slide

  2. ࣗݾ঺հ

    ⡥$MBTTNFUIPE *OD
    ໦ށࠃ඙!
    Ϋϥεϝιουגࣜձࣾɹ"84ίϯαϧςΟϯά෦
    ೖࣾ̎̌೔໨
    ੡඼։ൃνʔϜʹϓϩμΫτΦʔφʔͱ͍͏໾ׂͰ݄̎̍
    ೔͔ΒδϣΠϯ͠·ͨ͠ɻ·ͩ·ͩΘ͔Βͳ͍͜ͱ͹͔
    ΓͰ͕͢ΑΖ͓͘͠ئ͍͠·͢ɻN @@
    N
    ϒϩάʮ)FMMP&MBTUJDTFBSDIʯ΋ΑΖ͓͘͠ئ͍͠·͢
    ʲ޷͖ͳϓϩμΫτɺݴޠͳͲʳ

    View full-size slide

  3. ⡥$MBTTNFUIPE *OD

    ΞδΣϯμ
    Α͋͘Δ೰Έ
    ݕࡧɾ෼ੳͷ࢓૊Έ
    "OBMZTJTϞδϡʔϧ
    ެࣜ"OBMZTJTϞδϡʔϧ
    ΧελϜ"OBMZ[FS
    "OBMZTJTͷίϯτϩʔϧ
    ݴޠॲཧύλʔϯ
    ϚϧνɾϑΟʔϧυ
    "1*T

    View full-size slide

  4. &MBTUJDTFBSDIͰɺࣗ༝ࣗ
    ࡏʹݕࡧɾ෼ੳͰ͖ΔΑ͏
    ʹͳΔͨΊͷώϯτ
    !

    View full-size slide

  5. Α͋͘Δ೰Έ

    View full-size slide

  6. ⡥$MBTTNFUIPE *OD

    ࢥͬͨΑ͏ʹ෼ੳ
    Ͱ͖ͳ͍
    "

    View full-size slide

  7. ⡥$MBTTNFUIPE *OD

    ࢥͬͨΑ͏ʹݕࡧ
    Ͱ͖ͳ͍
    #

    View full-size slide

  8. ݕࡧɾ෼ੳͷ࢓૊Έ

    View full-size slide

  9. ⡥$MBTTNFUIPE *OD

    *OEFYJOHZPVSEBUB
    ݕࡧΤϯδϯ͸ɺݩͷσʔλΛͦͷ··อ
    ଘ͢ΔͷͰ͸ͳ͘ɺߴ଎ʹݕࡧͰ͖ΔΑ͏
    ʹτʔΫϯ୯ҐͰΠϯσοΫεΛ࡞͍ͬͯ·
    ͢ɻ̍࡭ͷຊʹྫ͑ΔͳΒຊͷ຤ඌʹ͋Δࡧ
    ҾΛ࡞ΔΠϝʔδ
    ࡧҾ

    Ϋϥεϝιου
    גࣜձࣾ
    ςΫϊϩδʔ
    %FWFMPQFST*0
    l೥࠷৽ͷࣄྫ΍ςΫϊϩδʔ͕
    Ұಊʹձ͢ΔΠϕϯτ%FWFMPQFST*0
    ։࠵͕ܾఆʂz
    $

    View full-size slide

  10. ⡥$MBTTNFUIPE *OD

    4FBSDIJOHZPVSEBUB
    ݕࡧͱ͸ɺ͋Β͔͡Ί࡞੒͞Ε͍ͯΔࡧҾʹ
    ରͯ͠ೖྗ͞ΕͨΩʔϫʔυ͕Ϛον͢Δυ
    Ωϡϝϯτநग़ͯ͠·͢ɻ
    (PPEʮ%FWFMPQFST*0ʯˠ'PVOE
    #BEʮEFWFMPQFSTʯˠ/PUGPVOE
    ࡧҾ

    Ϋϥεϝιου
    גࣜձࣾ
    ςΫϊϩδʔ
    %FWFMPQFST*0
    %FWFMPQFST*0

    #

    View full-size slide

  11. ⡥$MBTTNFUIPE *OD

    "OBMZ[JOHZPVSEBUB
    ࡧҾʢΠϯσοΫεʣͷτʔΫϯ͝ͱʹυ
    Ωϡϝϯτ਺Λूܭʢ5FSNT
    "HHSFHBUJPOʣ
    ͻΒ͕ͳ̍จࣈͰूܭ͞Εͯ͠·͏ͷ͸ɺࡧ
    ҾͻΒ͕ͳ̍จࣈͰ࡞ΒΕ͍ͯΔ͔Βɻ
    ࡧҾ

    Ϋϥεϝιου
    גࣜձࣾ
    ςΫϊϩδʔ
    %FWFMPQFST*0
    5FSN $PVOU
    גࣜձࣾ
    Ϋϥεϝιου
    %FWFMPQFST*0
    ςΫϊϩδʔ

    "

    View full-size slide

  12. ⡥$MBTTNFUIPE *OD
    ώϯτ
    ݕࡧ΋෼ੳ΋ࡧҾʢΠϯσοΫεʣ
    ΛͲ͏࡞Δ͔͕ॏཁ

    View full-size slide

  13. "OBMZTJTϞδϡʔϧ

    View full-size slide

  14. ⡥$MBTTNFUIPE *OD

    \*OEFY^
    \2VFSZ^
    \%PDVNFOU^
    */%&95*.& 4&"3$)5*.&
    "OBMZ[FS
    "OBMZ[FS͸ओʹೖྗ͞Εͨจࣈྻͷݴޠॲ
    ཧύΠϓϥΠϯॲཧΛఏڙ͠·͢ɻ
    ·ͨɺ"OBMZ[FSͰݴޠॲཧ͞ΕͨτʔΫϯ
    ୯ҐͰΠϯσοΫε͕࡞੒͞Ε·͢ɻ
    ΠϯσοΫεଆɿυΩϡϝϯτͷ಺༰ͷݴ
    ޠॲཧʹ࢖ΘΕ·͢ɻ
    αʔνଆɿݕࡧ࣌ͷೖྗΩʔϫʔυͷݴޠ
    ॲཧʹ࢖ΘΕ·͢ɻ
    "OBMZ[FS "OBMZ[FS
    $ #

    View full-size slide

  15. ⡥$MBTTNFUIPE *OD

    "OBMZ[FSͷߏ੒
    "OBMZ[FS͸ɺ$IBSBDUFS'JMUFSTɺ
    5PLFOJ[FSɺ5PLFO'JMUFSTͷॲཧηοτ͔
    Βߏ੒͞Ε͍ͯ·͢ɻ
    "OBMZ[FS͸ɺϑΟʔϧυ୯ҐʹॲཧΛ࣮ߦ
    ͠·͢ɻ
    \$IBSBDUFS'JMUFST^\5PLFOJ[FS^
    \5PLFO'JMUFST^
    5{\^\^\^{\^{\^\^\^{5`
    %"OBMZ[FS
    1JQFMJOF1SPDFTTJOH

    View full-size slide

  16. ⡥$MBTTNFUIPE *OD

    $IBSBDUFS'JMUFST
    $IBSBDUFS'JMUFS͸ɺओʹจࣈྻʹର͢Δ
    ਖ਼نԽॲཧΛ୲౰͢ΔॲཧεςʔδͰ͢ɻ
    ̍ͭͷ"OBMZ[FSʹ̌ݸҎ্ͷෳ਺ͷ
    $IBSBDUFS'JMUFSΛઃఆՄೳɻ
    ύΠϓϥΠϯͰॲཧ͞ΕΔͨΊͷॱ൪ʹ஫ҙ
    5{
    \^\^\^
    {\^{\^\^\^{5`
    1JQFMJOF1SPDFTTJOH
    \$IBSBDUFS'JMUFST^\5PLFOJ[FS^
    \5PLFO'JMUFST^
    lI̎̌̍̒೥࠷৽ͷࣄྫ΍ũŞůƁŢƄŖ͕Ұಊʹձ͢ΔŘųƄƃŪ%FWFMPQFST
    ̞̤։࠵͕ܾఆʂIz
    l೥࠷৽ͷࣄྫ΍ςΫϊϩδʔ͕Ұಊʹձ͢ΔΠϕϯτ
    %FWFMPQFST*0։࠵͕ܾఆʂz
    ਖ਼نԽ
    %"OBMZ[FS

    View full-size slide

  17. ⡥$MBTTNFUIPE *OD

    5PLFOJ[FS
    5PLFOJ[FS͸$IBSBDUFS'JMUFSTͰॲཧ͞
    ΕͨจࣈྻΛτʔΫϯԽ͢ΔͨΊͷॲཧε
    ςʔδͰ͢ɻ
    ̍ͭͷ"OBMZ[FSʹ̍ͭͷ"OBMZ[FSΛࢦఆ
    Մೳ
    5{\^\^\^{
    \^
    {\^\^\^{5`
    1JQFMJOF1SPDFTTJOH
    \$IBSBDUFS'JMUFST^\5PLFOJ[FS^
    \5PLFO'JMUFST^
    l೥࠷৽ͷࣄྫ΍ςΫϊϩδʔ͕Ұಊʹձ͢ΔΠϕϯτ
    %FWFMPQFST*0։࠵͕ܾఆʂz
    lz l೥z l࠷৽z lͷz lࣄྫz l΍z lςΫϊϩδʔz l͕zlҰಊz lʹz
    lձz l͢Δz lΠϕϯτz l%FWFMPQFSTz l*0z lz l։࠵z l͕z lܾఆz
    τʔΫϯԽ
    %"OBMZ[FS

    View full-size slide

  18. ⡥$MBTTNFUIPE *OD

    5PLFO'JMUFST
    5PLFO'JMUFS͸ɺ5PLFOJ[FSͰॲཧ͞Εͨ
    τʔΫϯΛ͞ΒʹՃ޻͢ΔͨΊͷॲཧεςʔ
    δͰ͢ɻ
    ̍ͭͷ"OBMZ[FSʹ̌ݸҎ্ͷෳ਺ͷ
    5PLFO'JMUFSΛઃఆՄೳɻ
    ύΠϓϥΠϯͰॲཧ͞ΕΔͨΊͷॱ൪ʹ஫ҙ
    5{\^\^\^{\^{
    \^\^\^
    {5`
    1JQFMJOF1SPDFTTJOH
    \$IBSBDUFS'JMUFST^\5PLFOJ[FS^
    \5PLFO'JMUFST^
    lz l೥z l࠷৽z lͷz lࣄྫz l΍z lςΫϊϩδʔz l͕zlҰಊz lʹz
    lձz l͢Δz lΠϕϯτz l%FWFMPQFSTz l*0z lz l։࠵z l͕z lܾఆz
    lz l࠷৽z lࣄྫz lςΫϊϩδʔz lҰಊz lΠϕϯτz l%FWFMPQFSTz
    l*0z lz l։࠵z lܾఆz
    Ճ޻
    %"OBMZ[FS

    View full-size slide

  19. ⡥$MBTTNFUIPE *OD
    ώϯτ
    "OBMZ[FS͸ϑΟʔϧυ୯ҐͰॲཧ
    ͞ΕΔ
    ΠϯσοΫεଆͱαʔνଆͰҟͳΔ
    "OBMZ[FS͕ඞཁʹͳΔέʔε΋͋
    Δ

    View full-size slide

  20. ެࣜ"OBMZTJTϞδϡʔϧ

    View full-size slide

  21. ⡥$MBTTNFUIPE *OD

    "OBMZ[FST
    TUBOEBSE
    TJNQMF
    XIJUFTQBDF
    TUPQ
    LFZXPSE
    QBUUFSO
    TOPXCBMM
    BSBCJD MBOHVBHF

    BSNFOJBO MBOHVBHF

    CBTRVF MBOHVBHF

    CSB[JMJBO MBOHVBHF

    CVMHBSJBO MBOHVBHF

    DBUBMBO MBOHVBHF

    DKL MBOHVBHF

    D[FDI MBOHVBHF

    EBOJTI MBOHVBHF

    EVUDI MBOHVBHF

    FOHMJTI MBOHVBHF

    pOOJTI MBOHVBHF

    GSFODI MBOHVBHF

    HBMJDJBO MBOHVBHF

    HFSNBO MBOHVBHF

    HSFFL MBOHVBHF

    IJOEJ MBOHVBHF

    IVOHBSJBO MBOHVBHF

    JOEPOFTJBO MBOHVBHF

    JSJTI MBOHVBHF

    JUBMJBO MBOHVBHF

    MBUWJBO MBOHVBHF

    MJUIVBOJBO MBOHVBHF

    OPSXFHJBO MBOHVBHF

    QFSTJBO MBOHVBHF

    QPSUVHVFTF MBOHVBHF

    SPNBOJBO MBOHVBHF

    SVTTJBO MBOHVBHF

    TPSBOJ MBOHVBHF

    TQBOJTI MBOHVBHF

    TXFEJTI MBOHVBHF

    UVSLJTI MBOHVBHF

    UIBJ MBOHVBHF

    LVSPNPKJ BOBMZTJTLVSPNPKJ

    QPMJTI BOBMZTJTTUFNQFM

    TNBSUDO BOBMZTJTTNBSUDO

    View full-size slide

  22. ⡥$MBTTNFUIPE *OD

    $IBSBDUFS
    'JMUFST
    NBQQJOH
    IUNM@TUSJQ
    QBUUFSO@SFQMBDF
    LVSPNPKJ@JUFSBUJPO@NBSL BOBMZTJTLVSPNPKJ

    JDV@OPSNBMJ[FS BOBMZTJTJDV

    View full-size slide

  23. ⡥$MBTTNFUIPE *OD

    5PLFO'JMUFST
    TUBOEBSE
    BTDJJGPMEJOH
    MFOHUI
    MPXFSDBTF
    VQQFSDBTF
    O(SBN
    FEHF/(SBN
    QPSUFS@TUFN
    TIJOHMF
    TUPQ
    XPSE@EFMJNJUFS
    TUFNNFS
    TUFNNFS@PWFSSJEF
    LFZXPSE@NBSLFS
    LFZXPSE@SFQFBU
    LTUFN
    TOPXCBMM
    QIPOFUJD
    TZOPOZN
    IZQIFOBUJPO@EFDPNQPV
    OEFS
    EJDUJPOBSZ@EFDPNQPVOE
    FS
    SFWFSTF
    FMJTJPO
    USVODBUF
    VOJRVF
    QBUUFSO@DBQUVSF
    QBUUFSO@SFQMBDF
    USJN
    MJNJU
    IVOTQFMM
    DPNNPO@HSBNT
    BSBCJD@OPSNBMJ[BUJPO
    HFSNBO@OPSNBMJ[BUJPO
    IJOEJ@OPSNBMJ[BUJPO
    JOEJD@OPSNBMJ[BUJPO
    TPSBOJ@OPSNBMJ[BUJPO
    QFSTJBO@OPSNBMJ[BUJPO
    TDBOEJOBWJBO@OPSNBMJ[B
    UJPO
    TDBOEJOBWJBO@GPMEJOH
    TFSCJBO@OPSNBMJ[BUJPO
    OPUSFMFBTFEZFU

    DKL@XJEUI
    DKL@CJHSBN
    EFMJNJUFE@QBZMPBE@pMUFS
    LFFQ
    LFFQ@UZQFT
    DMBTTJD
    BQPTUSPQIF
    EFDJNBM@EJHJU
    QIPOFUJD BOBMZTJT
    QIPOFUJD

    LVSPNPKJ@UPLFOJ[FS
    BOBMZTJTLVSPNPKJ

    LVSPNPKJ@CBTFGPSN
    BOBMZTJTLVSPNPKJ

    LVSPNPKJ@QBSU@PG@TQFFD
    I BOBMZTJTLVSPNPKJ

    LVSPNPKJ@SFBEJOHGPSN
    BOBMZTJTLVSPNPKJ

    LVSPNPKJ@TUFNNFS
    BOBMZTJTLVSPNPKJ

    KB@TUPQ BOBMZTJT
    LVSPNPKJ

    QPMJTI@TUFN BOBMZTJT
    TUFNQFM

    TNBSUDO@XPSE
    BOBMZTJTTNBSUDO

    TNBSUDO@TFOUFODF
    BOBMZTJTTNBSUDO

    JDV@OPSNBMJ[FS
    BOBMZTJTJDV

    JDV@GPMEJOH BOBMZTJT
    JDV

    JDV@DPMMBUJPO BOBMZTJT
    JDV

    JDV@USBOTGPSN BOBMZTJT
    JDV

    View full-size slide

  24. ⡥$MBTTNFUIPE *OD
    5PUBM

    View full-size slide

  25. ⡥$MBTTNFUIPE *OD
    ώϯτ
    ඞཁͳ"OBMZTJT͸΄ͱΜͲἧͬͯ
    Δ
    ΄ͱΜͲͷެࣜ"OBMZTJTϞδϡʔ
    ϧ͸ઃఆΛΧελϚΠζՄೳ

    View full-size slide

  26. ΧελϜ"OBMZ[FS

    View full-size slide

  27. ⡥$MBTTNFUIPE *OD
    ΧελϜ"OBMZ[FSͱ͸ʁ
    5PLFOJ[FS΍$IBSBDUFSpMUFSTɺ5PLFOpMUFSTΛ૊Έ߹Θͤͯɺಠࣗͷݕࡧཁ
    ݅΍ɺ෼ੳཁ݅Λ࣮ݱ͢ΔͨΊͷ"OBMZ[FSΛఆٛ͢Δ࢓૊ΈͰ͢ɻ

    PUT /my_index
    {
    "settings": {
    "analysis": {
    "char_filter": { ... custom character filters ... },
    "tokenizer": { ... custom tokenizers ... },
    "filter": { ... custom token filters ... },
    "analyzer": { ... custom analyzers ... }
    }
    }
    }

    View full-size slide

  28. ⡥$MBTTNFUIPE *OD
    ΧελϜ"OBMZ[FSͷఆٛɾద༻ɾ࣮ߦ

    *OEFY
    5ZQF .BQQJOH
    5ZQF .BQQJOH

    %PD %PD %PD %PD
    'JFME 'JFME 'JFME 'JFME 'JFME 'JFME 'JFME 'JFME
    ఆٛ
    ద༻
    ࣮ߦ
    ˞/PEFϨϕϧͰ΋ఆٛՄೳͰ͕͢ɺجຊతʹ͸*OEFYϨϕϧͰఆٛ͠·͠ΐ͏ɻ

    View full-size slide

  29. ⡥$MBTTNFUIPE *OD
    ώϯτ
    ΧελϜ"OBMZ[FS͸"OBMZTJT
    ϞδϡʔϧΛࣗ༝ʹ૊ΈΘͤͯઃఆ
    Ͱ͖Δ
    ·ͣ͸ɺެࣜ"OBMZTJTϞδϡʔϧ
    ͚ͩͰΧελϜ"OBMZ[FSΛઃܭ
    ΠϯσοΫεϨϕϧͰఆٛ͢Δ
    ϓϥάΠϯͷ։ൃ͸࠷ऴखஈ

    View full-size slide

  30. "OBMZTJTͷίϯτϩʔϧ

    View full-size slide

  31. ⡥$MBTTNFUIPE *OD
    "OBMZ[FSܾఆϑϩʔ

    45&1.BQQJOHͰఆٛ͞ΕͨJOEFY@BOBMZ[FS Y

    45&1%PDVNFOUͰఆٛ͞Εͨ@BOBMZ[FS Y

    45&15ZQFͰఆٛ͞ΕͨJOEFY@BOBMZ[FS Y

    45&1*OEFYͰఆٛ͞ΕͨEFGBVMU@JOEFY Y

    45&14UBOEBSE"OBMZ[FS
    45&1.BQQJOHͰఆٛ͞ΕͨBOBMZ[FS
    45&15ZQFͰఆٛ͞ΕͨBOBMZ[FS Y

    45&1*OEFYͰఆٛ͞ΕͨEFGBVMU
    45&1/PEFͰఆٛ͞ΕͨEFGBVMU@JOEFY Y

    45&1/PEFͰఆٛ͞ΕͨEFGBVMU
    45&12VFSZͰ໌ࣔతʹࢦఆ͞ΕͨBOBMZ[FS
    45&15ZQFͰఆٛ͞ΕͨTFBSDI@BOBMZ[FS Y

    45&1*OEFYͰఆٛ͞ΕͨEFGBVMU@TFBSDI
    45&14UBOEBSE"OBMZ[FS
    45&1.BQQJOHͰఆٛ͞ΕͨTFBSDI@BOBMZ[FS
    45&15ZQFͰఆٛ͞ΕͨBOBMZ[FS Y

    45&1*OEFYͰఆٛ͞ΕͨEFGBVMU
    45&1/PEFͰఆٛ͞ΕͨEFGBVMU@TFBSDI
    45&1/PEFͰఆٛ͞ΕͨEFGBVMU
    45&1.BQQJOHͰఆٛ͞ΕͨBOBMZ[FS
    JOEFYUJNF TFBSDIUJNF
    74

    View full-size slide

  32. ⡥$MBTTNFUIPE *OD
    {Full text queries}
    {Term level queries}
    VS

    View full-size slide

  33. ⡥$MBTTNFUIPE *OD

    'VMMUFYURVFSJFT
    'VMMUFYURVFSJFT͸ɺ"OBMZ[FSܾఆϑϩʔ
    ʹैܾͬͯఆ͞Εͨ"OBMZ[FSʹΑͬͯݴޠ
    ॲཧ͞Ε·͢ɻ
    \JOEFY^
    \'VMMUFYURVFSJFT^
    "OBMZ[F
    NBUDIRVFSZ
    NVMUJ@NBUDIRVFSZ
    DPNNPO@UFSNTRVFSZ
    RVFSZ@TUSJOHRVFSZ
    TJNQMF@RVFSZ@TUSJOH
    {
    "match" : {"user" : “Developers.IO"}
    }
    %FWFMPQFST*0
    EFWFMPQFSTJP

    View full-size slide

  34. ⡥$MBTTNFUIPE *OD

    5FSNMFWFMRVFSJFT
    5FSNMFWFMRVFSJFT͸ɺ"OBMZ[FSܾఆϑ
    ϩʔ͸ແࢹ͞Εɺݴޠॲཧ͸͞Ε·ͤΜɻ
    \*OEFY^
    \5FSNMFWFMRVFSJFT^
    /PU"OBMZ[F
    UFSNRVFSZ
    UFSNTRVFSZ
    SBOHFRVFSZ
    FYJTUTRVFSZ
    NJTTJOHRVFSZ
    QSFpYRVFSZ
    XJMEDBSERVFSZ
    SFHFYQRVFSZ
    GV[[ZRVFSZ
    UZQFRVFSZ
    JETRVFSZ
    {
    "term" : { "user" : “Developers.IO" }
    }
    %FWFMPQFST*0
    %FWFMPQFST*0

    View full-size slide

  35. ⡥$MBTTNFUIPE *OD
    ώϯτ
    "OBMZ[FS͸.BQQJOHϨϕϧͰ
    ໌ࣔతʹઃఆ
    σϑΥϧτ"OBMZ[FS͸*OEFYϨ
    ϕϧͰઃఆ

    View full-size slide

  36. ݴޠॲཧύλʔϯ

    View full-size slide

  37. ⡥$MBTTNFUIPE *OD

    /PU"OBMZ[FE
    ڀۃ͸෼ੳ͠ͳ͍
    ·ͣ͸ɺOPU@BOBMZ[FE͕ઃఆՄೳ͔ݕ౼͠
    ·͠ΐ͏ɻ

    View full-size slide

  38. ⡥$MBTTNFUIPE *OD

    4UBOEBSE
    "OBMZ[FS
    σϑΥϧτΞφϥΠβʔ
    ϤʔϩούܥݴޠΛݕࡧ͢ΔͨΊͷΞφϥ
    ΠβʔͰ͢ɻ
    ೔ຊޠ΋ҰԠݕࡧ͢Δ͜ͱ͸Ͱ͖·͕͢ɺ
    ׽ࣈɾͻΒ͕ͳ͸6OJHSBNͰΠϯσοΫε
    ͞ΕΔͨΊɺݕࡧ݁Ռͷద߹཰͸Լ͕Δ܏
    ޲ʹ͋Γ·͢ɻΧλΧφ͸۠੾ΒΕͳ͍ͨΊ
    ࠶ݱ཰͕Լ͕Δ܏޲

    View full-size slide

  39. ⡥$MBTTNFUIPE *OD

    ύολʔϯநग़
    ྫ͑͹ɺ63-ͷσʔλϑΟʔϧυΛ࢖ͬͯɺυϝΠϯ
    ໊Ͱूܭ͍ͨ͠
    lIUUQDMBTTNFUIPEKQDPNQBOZl
    lDMBTTNFUIPEKQz
    ਖ਼نදݱͰύολʔϯநग़

    View full-size slide

  40. ⡥$MBTTNFUIPE *OD

    Ϛοϐϯά
    ྫ͑͹ɺ౎ಓ෎ݝ໊Λؔ౦ͳͲΤϦΞͰूܭ͍ͨ͠
    l౦ژ౎l
    lؔ౦z
    ܾ·ͬͨ୯ޠͰஔ͖׵͑

    View full-size slide

  41. ⡥$MBTTNFUIPE *OD

    ܗଶૉղੳ
    ྫ͑͹ɺ೔ຊޠΛର৅ʹͨ͠ݕࡧͰɺద߹཰Λ޲্͠
    ͍ͨ
    l೥࠷৽ͷࣄྫ΍ςΫϊϩδʔ͕Ұಊ
    ʹձ͢ΔΠϕϯτ%FWFMPQFST*0։
    ࠵͕ܾఆʂz
    lz l೥z l࠷৽z lࣄྫz lςΫϊϩ
    δʔz lҰಊz lձz l͢Δz lΠϕϯτz
    l%FWFMPQFSTz l*0z lz l։࠵z lܾ
    ఆz
    ೔ຊޠͷ୯ޠ୯ҐʹτʔΫϯԽ

    View full-size slide

  42. ⡥$MBTTNFUIPE *OD

    /(SBN
    ྫ͑͹ɺ೔ຊޠΛର৅ʹͨ͠ݕࡧͰɺ࠶ݱ཰Λ޲্͠
    ͍ͨ
    l೥࠷৽ͷࣄྫ΍ςΫϊϩδʔ͕Ұಊ
    ʹձ͢ΔΠϕϯτ%FWFMPQFST*0։
    ࠵͕ܾఆʂz
    ೥ ೥࠷ ࠷৽ ৽
    ͷ ͷࣄ ྫ΍ ΍ς ςΫ Ϋϊ
    ϊϩ ϩδ δʔ ʔ͕ ͕Ұ Ұಊ
    ಊʹ ʹձ ձ͢ ͢Δ ΔΠ Πϕ
    ϕϯ ϯτ ϯE EF FW WF
    FM MP PQ QF FS ST T J
    JP J ։ ։࠵
    ࠵͕ ͕ܾ ܾఆ
    /จࣈ୯ҐʹτʔΫϯԽ

    View full-size slide

  43. ⡥$MBTTNFUIPE *OD

    $+,#JHSBN
    ྫ͑͹ɺӳɾ਺ࣈࠞ͡Γͷ೔ຊޠͷจষΛର৅ʹɺӳɾ
    ਺ࣈͷݕࡧͷద߹཰͸Լ͛ͣʹɺ೔ຊޠʢͻΒͳ͕ͳɺ
    ΧλΧφɺ׽ࣈʣͷ࠶ݱ཰Λ޲্͍ͤͨ͞
    l೥࠷৽ͷࣄྫ΍ςΫϊϩδʔ͕Ұಊ
    ʹձ͢ΔΠϕϯτ%FWFMPQFST*0։
    ࠵͕ܾఆʂz
    ೥࠷ ࠷৽ ৽ͷ ͷࣄ ྫ
    ΍ ΍ς ςΫ Ϋϊ ϊϩ ϩδ
    δʔ ʔ͕ ͕Ұ Ұಊ ಊʹ ʹձ
    ձ͢ ͢Δ ΔΠ Πϕ ϕϯ ϯτ
    EFWFMPQFSTJP ։࠵ ࠵͕
    ͕ܾ ܾఆ
    $+,ͷΈ/จࣈ୯ҐʹτʔΫϯԽ

    View full-size slide

  44. ⡥$MBTTNFUIPE *OD

    &EHF/(SBN
    ྫ͑͹ɺΩʔϫʔυ΍੡඼໊ͳͲଟগͷ༳Β͗Λٵऩ
    ͭͭ͠લํҰகͰݕࡧ͍ͨ͠ɻʢΩʔϫʔυαδΣε
    τʣ
    l%FWFMPQFST*0z
    E EF EFW EFWF EFWFM
    EFWFMP EFWFMPQ EFWFMPQF
    EFWFMPQFS EFWFMPQFST
    EFWFMPQFST EFWFMPQFSTJ
    EFWFMPQFSTJP EFWFMPQFSTJP
    EFWFMPQFSTJP EFWFMPQFSTJP
    EFWFMPQFSTJP EFWFMPQFSTJP

    ࢦఆൣғͷจࣈ਺ͰτʔΫϯԽ

    View full-size slide

  45. ⡥$MBTTNFUIPE *OD

    5PLFO/(SBN
    ྫ͑͹ɺ୯ޠͷ૊Έ߹ΘͤΛநग़͍ͨ͠
    l೥࠷৽ͷࣄྫ΍ςΫϊϩδʔ͕Ұಊ
    ʹձ͢ΔΠϕϯτ%FWFMPQFST*0։
    ࠵͕ܾఆʂz
    ࠷৽ࣄྫ ࣄྫςΫϊϩδʔ ςΫϊ
    ϩδʔҰಊ Ұಊձ ձΠϕϯτ Π
    ϕϯτEFWFMPQFST EFWFMPQFSTJP
    τʔΫϯΛϑϨʔζԽ

    View full-size slide

  46. ⡥$MBTTNFUIPE *OD

    ύολʔϯநग़
    ྫ͑͹ɺ63-ͷσʔλϑΟʔϧυΛ࢖ͬͯɺυϝΠϯ
    ໊͔Β೔ຊޠձ໊ࣾͰूܭද͍ࣔͨ͠
    lIUUQDMBTTNFUIPEKQDPNQBOZl
    lDMBTTNFUIPEKQz
    ਖ਼نදݱͰύολʔϯநग़
    Ϛοϐϯά

    ܾ·ͬͨ୯ޠͰஔ͖׵͑
    lΫϥεϝιουגࣜձࣾz

    View full-size slide

  47. ⡥$MBTTNFUIPE *OD

    &EHF/(SBN
    ྫ͑͹ɺ೔ຊޠͷจষʹରͯ͠Πϯελϯτݕࡧͨ͠
    ͍ɻʢ(PPHMFͷΠϯελϯτݕࡧʣ
    l೥࠷৽ͷࣄྫ΍ςΫϊϩδʔ͕Ұಊ
    ʹձ͢ΔΠϕϯτ%FWFMPQFST*0։
    ࠵͕ܾఆʂz
    ࠷ ࠷৽ ࣄ
    ࣄྫ ς ςΫ ςΫϊ ςΫϊϩ
    ςΫϊϩδ ςΫϊϩδʔ Ұ Ұಊ
    ձ Π Πϕ Πϕϯ lΠϕϯτz
    ୯ޠ͝ͱʹࢦఆൣғͷจࣈ਺ͰτʔΫϯԽ
    ܗଶૉղੳ

    ܗଶૉղੳͯ͠୯ޠ୯ҐʹτʔΫϯԽ

    View full-size slide

  48. ⡥$MBTTNFUIPE *OD

    5PLFO/(SBN
    ྫ͑͹ɺ೔ຊޠͷίϯςϯπ͔ΒϑϨʔζΛநग़ͯ͠
    ͦΕΛΩʔϫʔυαδΣετͰ࢖͍͍ͨ
    l೥࠷৽ͷࣄྫ΍ςΫϊϩδʔ͕Ұಊ
    ʹձ͢ΔΠϕϯτ%FWFMPQFST*0։
    ࠵͕ܾఆʂz
    ࠷ ࠷৽ ࠷৽ ࠷৽ࣄ ࠷৽ࣄྫ
    ࣄ ࣄྫ ࣄྫς ࣄྫςΫ ࣄ
    ྫςΫϊ ࣄྫςΫϊϩ ࣄྫςΫϊ
    ϩδ ࣄྫςΫϊϩδʔz
    ϑϨʔζΛࢦఆൣғͷจࣈ਺ͰτʔΫϯԽ
    ܗଶૉղੳ

    &EHF/(SBN

    ܗଶૉղੳͰ୯ޠ୯ҐʹτʔΫϯΜԽ
    ୯ޠΛϑϨʔζ୯ʹτʔΫϯԽ

    View full-size slide

  49. ⡥$MBTTNFUIPE *OD

    ΫϥελϦϯά
    ྫ͑͹ɺෳ਺ͷଐੑͷ஋Λ࢖ͬͯυΩϡϝϯτΛΫϥ
    ελϦϯά͍ͨ͠
    \2VFSJFT^
    \%PDVNFOU^
    1FSDPMBUF"1*
    ݕࡧ৚݅Λࣄલʹొ࿥͓͖ͯ͠ɺ೚ҙͷυΩϡϝϯ
    τʹϚον͢Δݕࡧ৚݅Λநग़͢Δಛघͳ࢓૊Έ
    SFRVFTU
    NBUDIRVFSJFT
    NFUB

    View full-size slide

  50. ⡥$MBTTNFUIPE *OD
    ώϯτ
    σʔλͷ಺༰Λ೺Ѳ
    ݕࡧɾ෼ੳཁ݅Λ೺Ѳ
    ·ͣ͸OPU@BOBMZ[FEઃఆՄೳ͔Ͳ
    ͏͔ݕ౼
    ݴޠॲཧύλʔϯΛϕʔεʹߟ͑Δ
    ݴޠॲཧύλʔϯͷ૊Έ߹ΘͤͯΈΔ

    View full-size slide

  51. ϚϧνɾϑΟʔϧυ

    View full-size slide

  52. .VMUJ'JFME
    ⡥$MBTTNFUIPE *OD
    ϚϧνɾϑΟʔϧυ

    UJUMF
    ܗଶૉղੳ"OBMZ[FS
    UJUMFTZOPOZN
    ܗଶૉղੳ4ZOPOZN
    "OBMZ[FS
    UJUMFTVCTUSJOH
    /(SBN"OBMZ[FS
    UJUMFUPQJD
    τϐοΫநग़"OBMZ[FS
    ݩσʔλͷεΩʔϚΛมߋͤͣʹ༻్ͷҟͳΔ"OBMZ[FSΛಉ
    ͡ϑΟʔϧυʹରͯ͠ෳ਺ఆٛ͢Δ͜ͱ͕Ͱ͖Δ࢓૊Έ

    View full-size slide

  53. ⡥$MBTTNFUIPE *OD
    ϚϧνɾϑΟʔϧυͷఆٛྫ

    PUT /my_index
    {
    "mappings": {
    "posts": {
    "properties": {
    "name": {
    "type": "string",
    "analyzer": "ja_analyzer",
    "fields": {
    "synonym": {
    "type": "string",
    "search_analyzer": "ja_analyzer",
    "analyzer": "ja_synonym_analyzer"
    },
    "substring": {
    "type": "string",
    "analyzer": "substring_analyzer"
    },
    "topic": {
    "type": "string",
    "search_analyzer": "keyword",
    "analyzer": "topic_analyzer"
    }
    }
    }
    }
    }
    }
    }
    ϚϧνɾϑΟʔϧυ

    View full-size slide

  54. ⡥$MBTTNFUIPE *OD
    ώϯτ
    ݩυΩϡϝϯτͷߏ଄Λมߋ͢Δલ
    ʹϚϧνɾϑΟʔϧυͰରԠՄೳ͔
    ݕ౼
    ϚϧνɾϑΟʔϧυͷ໊শΛඪ४Խ

    View full-size slide

  55. ⡥$MBTTNFUIPE *OD
    *OEFY5FNQMBUFT"1*
    *OEFYΛ࡞੒͢ΔࡍͷςϯϓϨʔτͷ؅ཧΛ͢ΔͨΊͷ"1*Ͱ͢ɻ
    $VTUPN"OBMZ[FSͷఆٛ΍.BQQJHOఆٛͳͲ͸ɺ*OEFY5FNQMBUFT"1*Λ࢖ͬͯςϯϓ
    Ϩʔτొ࿥͓ͯ͘͠ͱɺΠϯσοΫε࡞੒࣌ʹ͍͍ͪͪઃఆΛ͠ͳͯ͘΋ྑ͍ͷͰศརͰ͢ɻ

    PUT /_template/item_index_template
    {
    "template": "item*",
    "settings": {
    "analysis": {
    "char_filter": { ... custom character filters ... },
    "tokenizer": { ... custom tokenizers ... },
    "filter": { ... custom token filters ... },
    "analyzer": { ... custom analyzers ... }
    }
    },
    "mappings": { ... field mappings ...}
    }

    View full-size slide

  56. ⡥$MBTTNFUIPE *OD
    "OBMZ[F"1*
    ೚ҙͷจষΛ࢖ͬͯɺ"OBMZ[F͢Δ͜ͱ͕Ͱ͖Δ"1*Ͱ͢ɻ$VTUPN
    "OBMZ[FSΛઃఆͨ͠ࡍʹɺσʔλΛΠϯσοΫε͠ͳͯ͘΋ɺ͜ͷ"1*
    Λ࢖ͬͯ͋Δఔ౓ݕূ͢Δ͜ͱ͕Ͱ͖·͢ɻ

    POST /my_index/_analyze?analyzer=standard
    Hello! Elasticsearch
    {
    "tokens": [
    {
    "token": "hello",
    "start_offset": 0,
    "end_offset": 5,
    "type": "",
    "position": 0
    },
    {
    "token": "elasticsearch",
    "start_offset": 7,
    "end_offset": 20,
    "type": "",
    "position": 1
    }
    ]
    SFRVFTU SFTVMU

    View full-size slide

  57. ⡥$MBTTNFUIPE *OD
    (FU4FUUJOHT"1*
    ΠϯσοΫεͷઃఆ৘ใΛऔಘ͢ΔͨΊͷ"1*Ͱ͢ɻ$VTUPN
    "OBMZ[FSͳͲͷఆٛ৘ใΛऔಘ͢Δ͜ͱ͕Ͱ͖·͢ɻ

    GET /my_index/_settings {
    "my_index": {
    "settings": {
    "index": {
    "creation_date":
    "1455756138471",
    "number_of_shards": "5",
    "number_of_replicas": "1",
    "uuid": "PQ0f-0MlTtagrs-
    HeJHZ6Q",
    "version": {
    "created": "2020099"
    }
    }
    }
    }
    }
    SFRVFTU SFTVMU

    View full-size slide

  58. ⡥$MBTTNFUIPE *OD
    (FU.BQQJOH(FU'JFME.BQQJOH"1*
    ݱࡏઃఆ͞Ε͍ͯΔ.BQQJHఆٛΛऔಘ͢ΔͨΊͷ"1*Ͱ͢ɻϑΟʔϧυ
    ͷܕ΍ਖ਼͍͠"OBMZ[FS͕ઃఆ͞Ε͍ͯΔ͔ͳͲ֬ೝ͢Δ͜ͱ͕Ͱ͖·͢ɻ

    GET /my_index/_mapping/my_type {
    "my_index": {
    "mappings": {
    "my_type": {
    "properties": {
    "user": {
    "type": "string"
    }
    }
    }
    }
    }
    }
    SFTVMU
    SFRVFTU

    View full-size slide

  59. ⡥$MBTTNFUIPE *OD
    7BMJEBUF"1*1SPpMF"1*
    2VFSZ͕ਖ਼͍͠ॻࣜԽͲ͏͔ʁ·ͨɺΩʔϫʔυ͕ͲͷΑ͏ʹ"OBMZ[F
    ͞Εͯݕࡧ͍ͯ͠Δͷ͔ͳͲͷ৘ใΛऔಘ͢Δ͜ͱ͕Ͱ͖Δ"1*Ͱ͢ɻ

    POST /my_index/my_type/_validate/query?
    explain=true
    {
    "query": {
    "match": {
    "user": "Kimchy"
    }
    }
    }
    {
    "valid": true,
    "_shards": {
    "total": 1,
    "successful": 1,
    "failed": 0
    },
    "explanations": [
    {
    "index": "my_index",
    "valid": true,
    "explanation": "+user:kimchy
    #ConstantScore(+ConstantScore(_type:data))"
    }
    ]
    }
    SFRVFTU SFTVMU

    View full-size slide

  60. ⡥$MBTTNFUIPE *OD
    &YQMBJO"1*
    ೚ҙͷυΩϡϝϯτʹରͯ͠ɺ2VFSZ͕ͲͷΑ͏ʹϚον͍ͯ͠Δ͔ͳ
    Ͳͷ৘ใΛऔಘ͢Δ͜ͱ͕Ͱ͖·͢ɻ

    POST /my_index/my_type/1/_explain
    {
    "query": {
    "match": {
    "user": "Kimchy"
    }
    }
    }
    {
    "_index": "my_index",
    "_type": "my_type",
    "_id": "1",
    "matched": true,
    "explanation": {
    "value": 0.5945348,
    "description": "sum of:",
    "details": [
    {
    "value": 0.5945348,
    "description":
    "weight(user:kimchy in 0)
    [PerFieldSimilarity], result of:",
    "details": [
    {
    "value": 0.5945348,
    SFTVMU
    SFRVFTU

    View full-size slide

  61. ⡥$MBTTNFUIPE *OD
    ώϯτ
    ͍Ζ͍Ζศརͳ"1*Λ׆༻
    "OBMZ[FSͷݕূ͸σʔλΛΠϯ
    σοΫε͠ͳͯ͘΋ݕূͰ͖Δ

    View full-size slide

  62. ⡥$MBTTNFUIPE *OD
    ·ͱΊ
    w ެࣜͷ"OBMZTJTϞδϡʔϧͷ೺Ѳ
    w ϓϥάΠϯΛ։ൃ͢Δ͜ͱ΋Ͱ͖·͕͢ɺ·ͣ͸ެࣜͷ"OBMZTJTϞδϡʔϧΛ૊Έ߹Θ࣮ͤͯݱ
    Մೳ͔ݕ౼͍ͯͩ͘͠͞ɻ
    w σʔλͷ಺༰ͱݕࡧɾ෼ੳχʔζͷ೺Ѳ
    w ͜Ε͕ͳ͍ͱઃܭͰ͖·ͤΜɻ
    w কདྷతͳχʔζ΋ؚΊͯઃܭͰ͖Δͱͳ͓ྑ͍Ͱ͢ɻ
    w ݴޠॲཧύλʔϯͷཧղ
    w ݴޠॲཧύλʔϯΛϕʔεʹɺ͋ͱ͸ϑΟϧλʔͳͲͰݸผʹ੍౓Λ্͍͖͛ͯ·͠ΐ͏ɻ
    w ςϯϓϨʔτԽ
    w ࢖༻͢ΔΧελϜ"OBMZ[FS΍.BQQJOHఆٛ͸ςϯϓϨʔτԽͯ͠࢖͍·ΘͤΔΑ͏ʹ͠·͠ΐ
    ͏ɻ
    w "1*Λ࢖͍͜ͳ͢
    w ͍Ζ͍Ζ"1*͕͋ΔͷͰɺ͜ΕΒΛ࢖ͬͯઃܭɾݕূΛޮ཰Խ͠·͠ΐ͏ɻ

    View full-size slide

  63. ⡥$MBTTNFUIPE *OD
    ࠂ஌

    View full-size slide

  64. %FWFMPQFST*0
    ͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ɻ
    εϥΠυ͸ޙ೔ϒϩάͰެ։͠·͢ɻ

    $
    ⡥$MBTTNFUIPE *OD
    #cmdevio2016

    View full-size slide