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

ブログを支える技術

Takashi Masuda
February 17, 2017

 ブログを支える技術

Takashi Masuda

February 17, 2017
Tweet

More Decks by Takashi Masuda

Other Decks in Technology

Transcript

  1. • Unix Magazine 2002೥1݄߸ʰUnixͷϝϞٕज़ʱͰੈʹ஌Β ΕΔ • ChangeLogܗࣜΛ࠾༻ͨ͠1ͭͷςΩετϑΝΠϧ • ৘ใ͕1ͭͷϑΝΠϧʹ·ͱ·Δɻϙέοτ1ͭݪଇ •

    ৽͍͠ϝϞ͸ඞͣҰ൪্ʹͳΔͨΊɺ੔ཧͷඞཁ͕ͳ ͍ • ςΩετϑΝΠϧͳͷͰɺ࢖͍׳ΕͨΤσΟλͰૉૣ͘ ฤूͰ͖Δɻকདྷʹ౉ͬͯσʔλͷҠߦΛ৺഑͢Δඞ ཁ΋ͳ͍ http://0xcc.net/unimag/1/
  2. JavaScript • ҙ֎ͱ΍Δ͜ͱ͕ଟ͔ͬͨ • FlameworkʢVue.jsʣ • HTTP request with Ajaxʢaxiosʣ

    • ݕࡧΫΤϦ૊Έཱͯʢࣗલʣ • Paginationʢࣗલʣ • Routingʢࣗલʣ
  3. “ָ͍͠” { "query": { "bool": { "should": [ { "term":

    { "title": "ָ͍͠" } }, { "term": { "body": "ָ͍͠" } } ], "minimum_should_match": 1 } } } OR هࣄλΠτϧ هࣄຊจ
  4. “ָ͍͠ emacs” { "query": { "bool": { "must": [ {

    "bool": { "should": [ { "term": { "title": "ָ͍͠" } }, { "term": { "body": "ָ͍͠" } } ], "minimum_should_match": 1 } }, { "bool": { "should": [ { "term": { "title": "emacs" } }, { "term": { "body": "emacs" } } ], "minimum_should_match": 1 } } ] } } } AND
  5. ָ͍͠ -emacs { "query": { "bool": { "must": [ {

    "bool": { "should": [ { "term": { "title": "ָ͍͠" } }, { "term": { "body": "ָ͍͠" } } ], "minimum_should_match": 1 } } ], "must_not": [ { "bool": { "should": [ { "term": { "title": "emacs" } }, { "term": { "body": "emacs" } } ], "minimum_should_match": 1 } } ] } } } NOT
  6. nginxͷઃఆ upstream application-elasticsearch { server 0.0.0.0:9200; } server { listen

    443 ssl http2; server_name search.masutaka.net; # (snip) location / { add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Headers Content-Type; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $host; proxy_pass http://application-elasticsearch/chalow/article/_search; } } ElasticsearchΛ·Δ͝ͱެ։ ͯ͠͸͍ͳ͍͔Βେৎ෉ͩ ͱ͸ࢥ͏ɻ
  7. ςϯϓϨʔτͷ౤ೖ $ curl -X PUT 'http://localhost:9200/_template/chalow' -d ' { "template"

    : "chalow", "settings": { "index": { "analysis": { "tokenizer": { "kuromoji_user_dict": { "type": "kuromoji_tokenizer", "mode": "search" } } } } }, "mappings": { "article": { "properties": { "title": { "type": "string", "analyzer": "kuromoji", "fielddata": true, "fields": { "keyword": { "type": "keyword" } } }, "body": { "type": "string", "analyzer": "kuromoji", "fielddata": true, "fields": { "keyword": { "type": "keyword" } } } } } } } '
  8. هࣄσʔλͷ౤ೖ #!/bin/sh -eu TMP_JSON=chalow-es.json ES_URL=http://localhost:9200 ./script/html2json > $TMP_JSON curl -s

    -X DELETE $ES_URL/chalow curl -s -X POST $ES_URL/_bulk --data-binary @$TMP_JSON > /dev/null ※ σϓϩΠ࣌ʹ࣮ߦ͞ΕΔɻ./script/html2json͸Oga gemΛ࢖ͬͯHTMLͳهࣄΛύʔ ε͠ɺElasticsearch Bulk POSTͷͨΊͷjsonΛ࡞Δɻίʔυ͸ https://goo.gl/atnXVm
  9. Vue.jsͱͷग़ձ͍ • ReactɺAngularʹͳ͡Ίͳ ͔ͬͨ๻ʹखΛࠩ͠৳΂ ͯ͘ΕͨVue.js - Qiita [^1] • ࢲͨͪ͸ͳͥReactͰ͸ͳ

    ͘Vue.jsΛબΜͩͷ͔ | ϓ ϩάϥϛϯά | POSTD [^2] [^1]: https://goo.gl/kNE5If, [^2]: https://goo.gl/bB5Ej5
  10. Google Custom Search • GoogleͷΤϯδϯΛ࢖ͬͯɺ೚ҙͷαΠτΛݕࡧͰ͖ΔαʔϏε • GCP্͔ΒAPI KEYͱENGINE IDΛൃߦ͢Ε͹࢖͑Δ •

    ແྉ࿮ͷར༻੍ݶ͸100 queries/day • https://goo.gl/DgHyop • ࠷௿ྉۚ͸100USDʢ20,000 queries/yearʣ • https://goo.gl/wdxEXx