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

Elasticsearch trial and error

pisatoshi
November 12, 2013
4k

Elasticsearch trial and error

pisatoshi

November 12, 2013
Tweet

Transcript

  1. औΓ૊ΈͷܦҢ ॳ൛͸3VCZPO3BJMT $PVDI%# ݕࡧ͸DPVDIECMVDFOF ! ੑೳ εέʔϧΞ΢τ &SMBOHʹ࠳ં ! 

    ˠ+BWB &MBTUJDTFBSDIʹ৐Γ׵͑ ! ։ൃ͸ΞδϟΠϧͰ  ̎िؒຖͷϦϦʔε
  2.  3BJMT $PVDI%#Ͱ։ൃ։࢝    ࣮ূ࣮ݧ !  DPVDIECMVDFOFͷ୅ସͱͯ͠ݕ౼։࢝

     !  ։ൃ։࢝ɹ        !  Ќӡ༻։࢝ɹ        !  N#BB4ӡ༻։࢝ɹ       ·ͩ·ͩݱ໾ ! !                      #FUB औΓ૊ΈͷܦҢ
  3. ѻ͍ͬͯΔσʔλ ۀ຿σʔλ w εέδϡʔϧ w ϝοηʔδ w Ϣʔβʗ૊৫৘ใ w Ϛελʔσʔλ

    w ۀ຿ݻ༗ͷσʔλ   ɿ ! τϥοΩϯάσʔλ w ׆ಈϩά w ηϯαʔσʔλ ɹɹɹɿ { _XXXXX: XX_XX-XXX _XXXX: XXX_XXXXXXX_XXXXXXXXXXXXXXX-XXXXXX _XX: XXXXXX-XXXXXXXXXXXXXXX _XXXXXXX: X _XXXXX: XXXX _XXXXXX: { X: XXXXXXXXXXXXX X: { } X: XXXX_XXXXXXXX-XXXXXXXX X: { XXXXXXXXXXXXXXXXX: XXXX XXXXXXXXXXX: XXXXX XXXXXXXXXXXXXXX: X XXXXXXXXX: X XXXXXXXXXXXXXXX: XXXXX XXXXXXXX: XXXXXX XXXXXXXXXXXXXXXX: XXX.XXXXXXX.XXXXXXX.XXX.XXX.XXXXXX::XXXXXXXXXXXXX XXXXXXXXXX: XXX.XXXXXXX.XXXXXXX.XXX.XXX.XXXXXX::XXXXXXXXXXXXX XXXXXXXXXXXXXX: XXXX XXXXXXXXXXX: XXXXX XXXXXXX: XXXX XXXXXXXXXXXX: XXXXXXX-XX __XX: XXX_XXXXXXX:XXXXXX:XXXXXX XXXXXXX: XXXX-XX-XXXXX:XX:XX+XX:XX XXXXXXXXXXXXXXXXX: XXXX XXXXXXX: XXXX-XX-XXXXX:XX:XX+XX:XX XXXXXX: { "XXXXXXXXXXXXXX": XXXX, "XXXXXXXX": "", "XXXXXXXXXXXX": XXXX, "XXXXXXXXXXX": XXXX, "XXXXXXXXXXXXXXXX": "", "XXXXXXXXXXXXXXXXXXXXX": "", "XXXXXXXXX": "", "XXXXXXXX": "", "XXXXXXXXXXXX": [ ], "XXXXXXXXXXX": [ ], "XXXXXXXXXXXXXXXXXXX": [ ], "XXXXXXXXXXXXXXX": [ ], "XXXXXXXX": [ { "XXXXXXXX": "XXXXXXXXXXXXXXXXXX", "XXXXXXXXXXXX": "XXXXXXXXXXXX", "XXXXXXXXXXXXXX": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "XXXXXX": XXXX, "XXXXXXXXX": XXXX, "XXXXXXXXX": "XXXXXX", "XXXXXXXXXXXXXX": "XXXX", "XXXXXXXXXXX": "", "XXXX": "", "XXXXXXXXXXXX": "XXXXXXX-XX" } ], "XXXXXXXXX": [ ], "XXXXXXXXX": "", "XXXXXXXXXXXXXXX": [ { "XXXXXXXXX": "XXXX/XX/XX", "XXXXXX": "XXXXXXX", "XXXXXXXXXXXX": XXXX, "XXXXXXXXX": [ ], "XXXXXXXXXXXX": "XXXXXXX-XX", "XXXXXXXXXXX": "XXXXX", "XXXXXXX": "XXXX-XX-XXXXX:XX:XX+XX:XX" } ], "XXXXXXXXXXXXXXXXX": XXXX, "XXXXXXXXXXXXXXXX": XXXX, "XXXXXXXXXXXX": "", "XXXXXXXXXXX": "", "XXXXXXXXX": "", "XXXXXXXXX": "", "XXXXX": "", "XXXXXXXXXXX": "", "XXXXXXXX": "", "XXXXXXXXXX": "", "XXXXXX": "", "XXXXXXXX": "", "XXXX": "", "XXXXXX": "", "XXXXXXXX": "", "XXXXXXXXXXXXXXXXXXXX": "", "XXXXXXX": "", "XXXXXXXXXXXX": "", "XXXXXXXXXXXXXXXX": "", "XXXXXXXXXXXXXXXX": "", "XXXXXXXXXXXX": "", "XXXXXXXXXXXXXXXX": "", "XXXXXXX": "", "XXXXXXXXXXXXX": "", "XXXXXX": "", "XXXXXXXXXXX": "", "XXXXXXXXX": XXXXX, "XXXXXXXXXX": XXXXX, "XXXXXXXXXXX": "", "XXXXXXXXXXXX": { "XXXXXXXXX": XXXXX, "XXXXX": XX, "XXXXXXXXXXXXXXXXXX": "XXXXXXXX", "XXXXXXXXXXXX": "XXXXXXX-XX" }, "XXXXXXXXXXXXXXXXXX": XXXX, "XXXXXXXXXXXXXXXXXX": XXXX, "XXXXXXXXXXXXXXXX": XXXX, "XXXXXXXXXXXXXXXX": XXXX, "XXXXXXXXXXXXXXX": XXXX, "XXXXXXXXXXXXXXX": XXXX, "XXXXXXXXXXX": XXXX, "XXXXXXXXXXX": XXXX, "__XX": "XXXXXX", "XXXXXXXXX": "XXXXXX", "XXXX": "XXXXXX", "XXXX": "XXXXXXXXXXXXXXXXXX", "XXXXXXXX": "XXXX/XX/XX", "XXX": "X", "XXXXXX": "XXXXXXX", "XXXXXXXXXX": "", "XXXXXXX": "XXXX", "XXXXXXXXXX": [ ], "XXXXXXXXXX": [ ], "XXXXXXXXXXXXXXXXX": [ ], "XXXXXXXXXXXXXX": "", "XXXXXXXXXXXXX": "", "XXXXXXXXXXXXXXXXXXXXX": XXXX, "XXXXXXXXXXXXXXXXX": XXXXX, "XXXXXXXXX": "", "XXXXXXXXXXXXX": "", "XXXXXXXXXXXXXX": "", "XXXXXXXXXXXXX": "", "XXXXXXXXXXXXXXXXXXXXXXX": XXXX, "XXXXXXXXXXXXXXXXXXXXXXX": XXXX, "XXXXXXXXXXXXXXXXXXXXXXXXXXXX": XXXX, "XXXXXXXXXXXXXXXXXXXXXXXXXXXX": XXXX, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX": XXXX, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX": XXXX, "XXXXXXXXXXXXXXXX": XXXX, "XXXXXXXXXXXXXXXX": XXXX, "XXXXXXXXXXXXXXXXXXXXXXXX": XXXX, "XXXXXXXXXXXXXXXXXXXXXXXX": XXXX, "XXXXXXXXXXXXXXXXXX": XXXX, "XXXXXXXXXXXXXXXXXX": XXXX, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX": "", "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX": "", "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX": "", "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX": "", "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX": "", "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX": "", "XXXXXXXXXXXXXXXXXXXXXXXXXXX": "", "XXXXXXXXXXXXXXXXXXXXXXXXXXX": "", "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX": "", "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX": "", "XXXXXXXXXXXXXXX": { "XXXXXX": XXXXX, "XXXXXXXXXXXX": XXXXX }, "XXXXXXXXXXXXXXXX": XXXX, "XXXXXXXXXX": "", "XXXXXXXXXXXX": [ ], "XXXXXXXXXXXXXX": [ ], "XXXXXXXXXXX": XXXX, "XXXXXXXX": XXXX, "XXXXXXXXXXXX": "XXXXXXX-XX", "XXXXXXXXXX": "XXX.XXXXXXX.XXXXXXX.XXX.XXX.XXXXXX::XXXXXXXXXXXXX", "XXXXXXXXX": X, "XXXXXXX": "XXXX-XX-XXXXX:XX:XX+XX:XX", "XXXXXXXXXXX": "XXXXX", "XXXXXXXXXXXXXX": "XXXX-XX-XXXXX:XX:XX+XX:XX", "XXXXXXXXXXXXXXXXXX": "XXXXX", "XXXXXXXXXXX": "XXXXX", "XXXXXXX": "XXXX-XX-XXXXX:XX:XX+XX:XX" } XXXXXXXX: XXXX XXXXXXXXXXXXXXXXXX: XXXX XXXXXXXXXXXXXXXX: XXX_XXXXXXX:XXXXXX } X: XXXXXXXXXXXXXXXXXXXXXX X: XXXXXXXXXXXXX X: XXXXXXXXXXXXXXX-XXXXXX X: { XXX_XXXXXXX: XXXXXX_XXXXXXXXXXXXXXX } X: { } } XXXX: [ XXX_XXXXXXX_XXXXXXXXXXXXXXX-XXXXXX XXX_XXXXXXX:XXXXXX:XXXXXX ] } +40/ʢΠϝʔδʣ ۀ຿ͷσʔλ͸ෳࡶͰ֊૚͕ ਂ͘ͳΓ͕ͪ
  4. υΩϡϝϯτొ࿥ *OEFY3FRVFTU#VJMEFSSFRUSBOTQPSU$MJFOUQSFQBSF*OEFY JOEFY UZQF JE    TFU0Q5ZQF PQ5ZQF

       TFU4PVSDF EBUB    TFU$POTJTUFODZ-FWFM 8SJUF$POTJTUFODZ-FWFM%&'"6-5    TFU3FGSFTI USVF    TFU3PVUJOH SPVUJOH*E  SFUVSOSFRFYFDVUF BDUJPO(FU  ! υΩϡϝϯτऔಘ (FU3FRVFTUSFROFX(FU3FRVFTU JOEFY UZQF JE    SPVUJOH SPVUJOH*E    SFBMUJNF SFBMUJNF  SFUVSOUSBOTQPSU$MJFOUHFU SFR BDUJPO(FU  ! ݕࡧ 4FBSDI3FRVFTUSFROFX4FBSDI3FRVFTU JOEFY    UZQFT UZQF    TFBSDI5ZQF 4FBSDI5ZQF%&'"6-5    TPVSDF CVJMEFS    SPVUJOH SPVUJOH*E  SFUVSOUSBOTQPSU$MJFOUTFBSDI SFR BDUJPO(FU  ϧʔςΟϯάʹΑΔੑೳ޲্
  5. %ZOBNJD.BQQJOHͷ໰୊ &MBTUJDTFBSDIͰ͸εΩʔϚϑϦʔ͕΢Ϧ  %ZOBNJD.BQQJOH  ೖྗσʔλ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YpFMEEBUBEPVCMFT%PVCMF'JFME%BUB5ZQF!BB>2VFSZ'BJMFE<'BJMFEUPFYFDVUFNBJO RVFSZ>>OFTUFE/VNCFS'PSNBU&YDFQUJPO<*OWBMJETIJGUWBMVFJOQSFpY$PEFETUSJOH JTFODPEFEWBMVFSFBMMZB-0/( > ^> ^  IJUT\ UPUBM  NBY@TDPSFOVMM  IJUT<> ^ ^
  9. σʔλܕͷίϯϑϦΫτ ιʔτΩʔΛࢦఆ͠ͳ͚Ε͹େৎ෉ ! DVSM91045TIUUQMPDBMIPTUUFTUUZQF@TFBSDI QSFUUZEb\ lTJ[F  RVFSZ\ NBUDI@BMM\^ ^

    ^ \ UPPL  UJNFE@PVUGBMTF  @TIBSET\ UPUBM  TVDDFTTGVM  GBJMFE ^  IJUT\ UPUBM  NBY@TDPSF  IJUT<> ^ ^
  10. Ϛοϐϯάఆٛ͸ΞϓϦͰ੍ޚ Elasticsearchͷܕࣗಈ൑ผ͸࢖Θͳ͍! ༧ΊશͯͷσʔλܕΛMultiFieldܕͰϚοϐϯά! ! ! ! ! ༧ΊશͯͷϚοϐϯάΛఆٛ! ! Ϛοϐϯάͷ࠷େαΠζΛݻఆ

    →ͦΕҎ্ͷංେԽΛ๷ࢭ! MultiFieldͰϚοϐϯά! ! จࣈྻ(analyzed, not analyzed)ɺ਺஋(long, double)! ! σʔλܕͷίϯϑϦΫτΛճආ
  11. \ 4BNQMF%BUB\ EBUF@EFUFDUJPOGBMTF  EZOBNJD@UFNQMBUFT< \ QSPQFSUJFT\ NBUDI  

    NBQQJOH\ UZQFNVMUJ@pFME  pFMET\ EPVCMF\UZQFlEPVCMF JHOPSF@NBMGPSNFEUSVF JODMVEF@JO@BMMGBMTF^  MPOH\UZQFlMPOH JHOPSF@NBMGPSNFEUSVF JODMVEF@JO@BMMGBMTF^  VOUPVDIFE\UZQFlTUSJOH JOEFYlOPU@BOBMZ[FE JODMVEF@JO@BMMGBMTF^  \OBNF^\UZQFlTUSJOH JOEFYlBOBMZ[FE^ ^ ^ ^ ^ > ^ ^ Ϛοϐϯάఆٛ͸ΞϓϦͰ੍ޚ
  12. !#FGPSF$MBTT QVCMJDTUBUJDWPJETFU6Q UISPXT&YDFQUJPO\ 'JMF6UJMTDPQZ%JSFDUPSZ    OFX'JMF lTSDUFTUSFTPVSDFTEBUBTFU 

      OFX'JMF lQBUIUPUFTUEBUBz  ! 4FUUJOHTTFUUJOHT*NNVUBCMF4FUUJOHTTFUUJOHT#VJMEFS  QVU OPEFIUUQFOBCMFE USVF  QVU DMVTUFSOBNF UFTUJOHDMVTUFS  QVU OPEFOBNF UFTUJOHOPEF  QVU OPEFNBTUFS USVF  QVU OPEFEBUB USVF  QVU QBUIEBUB lQBUIUPUFTUEBUBz  QVU JOEFYOVNCFS@PG@TIBSET   QVU JOEFYOVNCFS@PG@SFQMJDBT   QVU USBOTQPSUUDQQPSU   CVJME  OPEF/PEF#VJMEFSOPEF#VJMEFS TFUUJOHT TFUUJOHT OPEF  ^ ! !"GUFS$MBTT QVCMJDTUBUJDWPJEUFBS%PXO UISPXT&YDFQUJPO\ OPEFDMPTF  'JMF6UJMEFMFUF%JSFDUPSZ OFX'JMF lQBUIUPUFTUEBUBz  ^ Ϣχοτςετ