{"id":550,"date":"2021-03-07T09:40:11","date_gmt":"2021-03-07T00:40:11","guid":{"rendered":"http:\/\/localhost:8000\/?p=550"},"modified":"2021-04-05T13:23:00","modified_gmt":"2021-04-05T04:23:00","slug":"elasticsearch-part2","status":"publish","type":"post","link":"http:\/\/localhost:8000\/2021\/03\/elasticsearch-part2.html","title":{"rendered":"Elasticsearch\u306e\u4f7f\u3044\u65b9 part2"},"content":{"rendered":"
\u5148\u65e5\u3001Elasticsearch\u306e\u4f7f\u3044\u65b9<\/a>\u3068\u3044\u3046\u8a18\u4e8b\u3092\u66f8\u304d\u307e\u3057\u305f\u304c\u3001\u3053\u3053\u306b\u66f8\u304d\u304d\u308c\u306a\u304b\u3063\u305fTips\u3084\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9\u306b\u3064\u3044\u3066\u7d39\u4ecb\u3057\u3088\u3046\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n Elasticsearch version: 7.11<\/p>\n Elasticsearch\u3067\u306f\u65e2\u5b58\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u76f4\u63a5\u5909\u66f4\u3067\u304d\u306a\u3044\u306e\u3067\u3001\u65b0\u3057\u3044\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u4f5c\u3063\u3066\u5207\u308a\u66ff\u3048\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002 \u4f8b\u3048\u3070\u3001 \u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306e\u5909\u66f4\u304c\u5fc5\u8981\u306b\u306a\u3063\u305f\u5834\u5408\u306f\u3001\u65b0\u3057\u304f \u3053\u3046\u3057\u3066\u304a\u3051\u3070\u3001Elasticsearch\u3092\u5229\u7528\u3059\u308b\u5074\u306f\u5e38\u306b \u307e\u305a\u524d\u63d0\u3068\u3057\u3066\u3001Elasticsearch\u3067\u306f\u57fa\u672c\u7684\u306b\u306f\u4e00\u5ea6\u4f5c\u6210\u3057\u305f\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u5909\u66f4\u3059\u308b\u3053\u3068\u306f\u3067\u304d\u306a\u3044\u306e\u3067\u3001\u610f\u5916\u306b\u5927\u5909\u306a\u4f5c\u696d\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n \u3082\u3063\u3068\u3082\u6c4e\u7528\u7684\u306a\u65b9\u6cd5\u306f\u3001Create Index API<\/a>\u3092\u4f7f\u3063\u3066\u3001\u65b0\u3057\u3044\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u4f5c\u6210\u3057\u3066\u304a\u3044\u3066\u3001\u30c7\u30fc\u30bf\u3092\u4e00\u304b\u3089\u767b\u9332\u3057\u306a\u304a\u3059\u3068\u3044\u3046\u65b9\u6cd5\u3067\u3059\u3002 \u3068\u3044\u3046\u308f\u3051\u3067\u3001Elasticsearch\u306e\u4e2d\u3060\u3051\u3067\u5b8c\u7d50\u3059\u308b\u30b1\u30fc\u30b9\u3092\u3044\u304f\u3064\u304b\u7d39\u4ecb\u3057\u3088\u3046\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n https:\/\/stackoverflow.com\/questions\/43120430\/elasticsearch-mapping-rename-existing-field<\/a><\/p>\n \u4f8b\u3048\u3070\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b \u307e\u305a\u3001\u30c7\u30fc\u30bf\u53d6\u308a\u8fbc\u307f\u7528\u306e Ingest Node Pipeline<\/a> \u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n \u5148\u307b\u3069\u5b9a\u7fa9\u3057\u305f\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u3092\u6307\u5b9a\u3057\u3066\u3001Reindex API<\/a> \u3092\u4f7f\u3063\u3066\u3001\u65b0\u3057\u3044\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n \u65b0\u3057\u304f\u4f5c\u6210\u3055\u308c\u305f\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306e\u5b9a\u7fa9\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3001\u3061\u3083\u3093\u3068\u9805\u76ee\u540d\u304c\u5909\u66f4\u3055\u308c\u307e\u3057\u305f\u3002 \u4f8b\u3048\u3070\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b kuromoji \u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u306b\u3064\u3044\u3066\u306f\u3001\u8a18\u4e8b\u306e\u5f8c\u534a\u306b\u8a18\u8f09\u3057\u3066\u3044\u307e\u3059\u3002 \u3042\u3068\u306f\u3001Reindex API<\/a> \u3092\u4f7f\u3063\u3066\u3001 \u3053\u308c\u3067\u3001 \u4f8b\u3048\u3070\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b \u307e\u305a\u306f\u3001\u30d5\u30a3\u30fc\u30eb\u30c9\u8ffd\u52a0\u5f8c\u306e \u6b21\u306b\u3001\u30c7\u30fc\u30bf\u53d6\u308a\u8fbc\u307f\u7528\u306e Ingest Node Pipeline<\/a> \u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n \u6700\u5f8c\u306b\u3001Reindex API<\/a> \u3092\u4f7f\u3063\u3066\u3001 \u3053\u308c\u3067\u3001 \u691c\u7d22\u6642\u306b\u6307\u5b9a\u3057\u305f\u30ef\u30fc\u30c9\u3092\u3001\u691c\u7d22\u7d50\u679c\u5185\u3067\u30cf\u30a4\u30e9\u30a4\u30c8\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002 \u4eca\u56de\u306f\u3001 kuromoji \u3067\u30a2\u30ca\u30e9\u30a4\u30ba\u3057\u305f\u3001 \u7d50\u679c\uff08\u30cf\u30a4\u30e9\u30a4\u30c8\u90e8\u5206\u3060\u3051\u629c\u7c8b\uff09\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n \u4ee5\u4e0b\u306e\u3053\u3068\u304c\u5206\u304b\u308a\u307e\u3059\u3002<\/p>\n \u30d5\u30e9\u30b0\u30e1\u30f3\u30c8\u306f\u7d50\u679c\u306e\u30c7\u30fc\u30bf\u91cf\u3092\u6e1b\u3089\u3059\u610f\u5473\u3067\u306f\u826f\u3044\u306e\u3067\u3059\u304c\u3001\u7d50\u679c\u3092\u753b\u9762\u306b\u8868\u793a\u3059\u308b\u3088\u3046\u306a\u5834\u5408\u306b\u306f\u3001\u30d5\u30a3\u30fc\u30eb\u30c9\u306e\u5168\u6587\u306b\u5bfe\u3057\u3066 \u3042\u3068\u306f\u3001query\u5bfe\u8c61\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u3057\u304b\u30cf\u30a4\u30e9\u30a4\u30c8\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u305b\u3093\u3002<\/p>\n Elasticsearch\u3067\u3082\u96c6\u8a08\u3092\u884c\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002 \u96c6\u8a08\u306e\u7a2e\u985e\u306f\u5927\u304d\u304f\u4e09\u3064\u3042\u308b\u307f\u305f\u3044\u3067\u3059\u3002<\/p>\n \u7d50\u679c\u306f\u3001\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n \u4f8b\u3068\u3057\u3066\u3001\u4ee5\u4e0b\u306e\u4e8c\u3064\u3092\u3084\u3063\u3066\u307f\u3088\u3046\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n \u7d50\u679c\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n \u300c\u5e74\u9f62\u306e\u7bc4\u56f2\u6307\u5b9a\u300d\u3082\u300c\u5358\u8a9e\u306e\u6587\u66f8\u983b\u5ea6\u96c6\u8a08\u300d\u3082\u3001\u6982\u306d\u60f3\u5b9a\u901a\u308a\u306e\u7d50\u679c\u304c\u8fd4\u3063\u3066\u304d\u307e\u3057\u305f\u3002<\/p>\n \u30d0\u30b1\u30c3\u30c8\u96c6\u8a08\u3057\u305f\u7d50\u679c\u3092\u3001\u3055\u3089\u306b\u30d0\u30b1\u30c3\u30c8\u96c6\u8a08\u3084\u30e1\u30c8\u30ea\u30c3\u30af\u96c6\u8a08\u3059\u308b\u3053\u3068\u3067\u3001\u8907\u96d1\u306a\u96c6\u8a08\u3092\u5b9f\u73fe\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002 \u4eca\u56de\u306e\u30c7\u30fc\u30bf\u3060\u3068\u5168\u304f\u610f\u5473\u306e\u306a\u3044\u96c6\u8a08\u306b\u306a\u3063\u3066\u3057\u307e\u3046\u306e\u3067\u3059\u304c\u3001 \u7d50\u679c\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3057\u305f\u3002 \u65e5\u672c\u8a9e\u30c6\u30ad\u30b9\u30c8\u306e\u5206\u6790\u306e\u305f\u3081\u306b kuromoji \u30d7\u30e9\u30b0\u30a4\u30f3<\/a>\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u30b1\u30fc\u30b9\u3092\u8003\u3048\u307e\u3059\u3002 \u307e\u305a\u3001Dockerfile \u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n docker-compose.yml \u3067\u3001Dockerfile\u3092\u5229\u7528\u3059\u308b\u3088\u3046\u306b\u5909\u66f4\u3057\u307e\u3059\u3002 \u3042\u3068\u306f\u3001Docker\u30b3\u30f3\u30c6\u30ca\u3092\u8d77\u52d5\u3059\u308b\u3060\u3051\u3067\u3059\u3002<\/p>\n Elasticsearch\u306f\u3001RDB\u3068\u9055\u3063\u3066\u6587\u5b57\u5217\u306e\u6271\u3044\u3084\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306e\u6271\u3044\u304c\u601d\u3063\u305f\u3088\u308a\u5927\u5909\u3067\u3057\u305f\u3002 \u4eca\u56de\u306e\u30b3\u30fc\u30c9\u306f\u4e00\u5fdc\u4ee5\u4e0b\u3067\u516c\u958b\u3057\u3066\u307e\u3059\u3002 \u5148\u65e5\u3001Elasticsearch\u306e\u4f7f\u3044\u65b9\u3068\u3044\u3046\u8a18\u4e8b\u3092\u66f8\u304d\u307e\u3057\u305f\u304c\u3001\u3053\u3053\u306b\u66f8\u304d\u304d\u308c\u306a\u304b\u3063\u305fTips\u3084\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9\u306b\u3064\u3044\u3066\u7d39\u4ecb\u3057\u3088\u3046\u3068\u601d\u3044\u307e\u3059\u3002 Elasticsearch version: 7.11 \u6587\u5b57\u5217\u3092\u6271\u3046text\u3068keyword\u306e\u9055\u3044 text\u578b index\u767b\u9332\u6642\u306b\u30a2\u30ca\u30e9\u30a4\u30b6\u30fc\u306b\u3088\u3063\u3066\u51e6\u7406\u3055\u308c\u3001\u30c8\u30fc\u30af\u30f3\u306b\u5206\u5272\u3055\u308c\u3066\u4fdd\u5b58\u3055\u308c\u308b \u30a2\u30ca\u30e9\u30a4\u30b6\u30fc\u306f\u4ee5\u4e0b\u306e3\u3064\u3067\u69cb\u6210\u3055\u308c\u308b Char Filter \u30c8\u30fc\u30af\u30f3\u3092\u8a8d\u8b58\u305b\u305a\u306b\u884c\u3048\u308b\u6a5f\u68b0\u7684\u306a\u5909\u63db\u51e6\u7406 \u5927\u6587\u5b57\u3001\u5c0f\u6587\u5b57\u5909\u63db\u3001\u7279\u6b8a\u6587\u5b57\u6b63\u898f\u5316\u3001\u6b63\u898f\u8868\u73fe\u306b\u3088\u308b\u62bd\u51fa\u306a\u3069 Tokenizer \u6587\u5b57\u5217\u3092\u30c8\u30fc\u30af\u30f3\u306b\u5206\u5272\u3059\u308b\uff08\u5206\u304b\u3061\u66f8\u304d\u3059\u308b\uff09 \u5f62\u614b\u7d20\u89e3\u6790\u3001N-gram\u3001\u7279\u5b9a\u6587\u5b57\u3067split\u306a\u3069 Token Filter \u30c8\u30fc\u30af\u30f3\u306b\u5bfe\u3057\u3066\u306e\u5909\u63db\u51e6\u7406 \u30b9\u30c8\u30c3\u30d7\u30ef\u30fc\u30c9\u9664\u53bb\u3001\u30b9\u30c6\u30df\u30f3\u30b0\u306a\u3069 \u30d5\u30ec\u30fc\u30ba\u691c\u7d22\u304c\u3067\u304d\u308b \u3044\u308f\u3086\u308b\u300c\u5168\u6587\u691c\u7d22\u300d\u304c\u3067\u304d\u308b\u3068\u3044\u3046\u3053\u3068 \u30c8\u30fc\u30af\u30f3\u306b\u5206\u304b\u308c\u3066\u3044\u308b\u306e\u3067\u3001\u8907 <\/span>Continue Reading<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[37],"tags":[],"_links":{"self":[{"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/posts\/550"}],"collection":[{"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/comments?post=550"}],"version-history":[{"count":1,"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/posts\/550\/revisions"}],"predecessor-version":[{"id":551,"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/posts\/550\/revisions\/551"}],"wp:attachment":[{"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/media?parent=550"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/categories?post=550"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/tags?post=550"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}\u6587\u5b57\u5217\u3092\u6271\u3046text\u3068keyword\u306e\u9055\u3044<\/h2>\n
\n
\n
\n
\n
\n
\n
\n
\n
fielddata: true<\/code>\u3092\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u3067\u4f7f\u3048\u308b\u3088\u3046\u306b\u306a\u308b<\/li>\n
\n
\n
\n
\n
\n
\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3078\u306e\u30a8\u30a4\u30ea\u30a2\u30b9\u8a2d\u5b9a<\/h2>\n
\n\u3068\u306f\u3044\u3048\u3001\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u540d\u304c\u5909\u308f\u308b\u3068\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u5229\u7528\u7b87\u6240\u3092\u5168\u3066\u5909\u66f4\u3057\u3066\u3044\u304f\u5fc5\u8981\u304c\u3042\u308a\u5927\u5909\u3067\u3059\u3002
\n\u305d\u3046\u306a\u3089\u306a\u3044\u3088\u3046\u306b\u3001\u4e8b\u524d\u306b\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306b\u5bfe\u3057\u3066\u30a8\u30a4\u30ea\u30a2\u30b9\u3092\u8a2d\u5b9a\u3057\u3066\u304a\u304f\u3053\u3068\u3092\u304a\u52e7\u3081\u3057\u307e\u3059\u3002<\/p>\n\n
\n
warloads_202102<\/code> <=
warloads<\/code>\uff08\u30a8\u30a4\u30ea\u30a2\u30b9\uff09<\/li>\n<\/ul>\n<\/li>\n
\n
warloads_202102<\/code><\/li>\n
warloads_202103<\/code> <=
warloads<\/code>\uff08\u30a8\u30a4\u30ea\u30a2\u30b9\uff09<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n
warloads<\/code> \u3068\u3044\u3046\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u4f5c\u6210\u3057\u305f\u3044\u5834\u5408\u3001\u5909\u66f4\u306b\u5099\u3048\u3066\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u540d\u3092
warloads_202102<\/code> \u3068\u3057\u3066\u304a\u304d\u3001
warloads<\/code>\u3068\u3044\u3046\u30a8\u30a4\u30ea\u30a2\u30b9\u3092\u8a2d\u5b9a\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n
curl -H 'Content-type: application\/json' -XPOST 'http:\/\/localhost:9200\/_aliases' -d '{\n "actions": [\n {\n "add": {\n "index": "warloads_202102",\n "alias": "warloads"\n }\n }\n ]\n}'<\/code><\/pre>\n
warloads_202103<\/code> \u3068\u3044\u3046\u540d\u524d\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u4f5c\u6210\u3057\u3066\u3001\u30a8\u30a4\u30ea\u30a2\u30b9\u3092\u8cbc\u308a\u66ff\u3048\u307e\u3059\u3002<\/p>\n
curl -H 'Content-type: application\/json' -XPOST 'http:\/\/localhost:9200\/_aliases' -d '{\n "actions": [\n {\n "remove": {\n "index": "warloads_202102",\n "alias": "warloads"\n }\n },\n {\n "add": {\n "index": "warloads_202103",\n "alias": "warloads"\n }\n }\n ]\n}'<\/code><\/pre>\n
warloads<\/code> \u3067\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b\u306e\u3067\u3001\u5b89\u5fc3\u3067\u3059\u3002<\/p>\n
\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u5909\u66f4<\/h2>\n
\u6c4e\u7528\u7684\u306a\u65b9\u6cd5<\/h3>\n
\n\u3053\u308c\u306f\u5358\u7d14\u306a\u306e\u3067\u3059\u304c\u3001\u4ef6\u6570\u304c\u591a\u304f\u306a\u3063\u3066\u304f\u308b\u3068\u5b9f\u884c\u6642\u9593\u3082\u304b\u304b\u308b\u3057\u3001\u5143\u30c7\u30fc\u30bf\u304c\u540c\u4e00\u3067\u3042\u308b\u3053\u3068\u3092\u62c5\u4fdd\u3059\u308b\u306e\u304c\u5927\u5909\u306a\u306e\u3067\u3067\u304d\u308c\u3070\u907f\u3051\u305f\u3044\u3068\u3053\u308d\u3067\u3059\u3002<\/p>\n\u30d5\u30a3\u30fc\u30eb\u30c9\u540d\u3092\u5909\u66f4\u3057\u305f\u3044\u3060\u3051\u306e\u30b1\u30fc\u30b9<\/h3>\n
warloads_202102<\/code>\u3068\u3044\u3046\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306b\u304a\u3044\u3066
\n\u30d5\u30a3\u30fc\u30eb\u30c9\u540d\u3092 age<\/code> =>
death_age<\/code> \u306b\u5909\u66f4\u3059\u308b\u30b1\u30fc\u30b9\u3092\u8003\u3048\u307e\u3059\u3002<\/p>\n
{\n "warloads_202102": {\n "mappings": {\n "properties": {\n "age": { \/\/ \u3053\u3053\u3092 death_age \u306b\u5909\u66f4\u3059\u308b\n "type": "long"\n }\n }\n }\n }\n}<\/code><\/pre>\n
curl -H 'Content-type: application\/json' -XPUT 'http:\/\/localhost:9200\/_ingest\/pipeline\/warloads_rename_age_to_death_age_pipeline' -d '{\n "processors": [\n {\n "rename": {\n "field": "age",\n "target_field": "death_age",\n "ignore_missing": true\n }\n }\n ]\n}'<\/code><\/pre>\n
\n
age<\/code>\u4ee5\u5916\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u306b\u3064\u3044\u3066\u306f\u3001\u7279\u306b\u6307\u5b9a\u3059\u308b\u5fc5\u8981\u306a\u3057<\/li>\n
ignore_missing<\/code>\u306f\u4eca\u56de\u306f\u6307\u5b9a\u3057\u306a\u304f\u3066\u3082\u554f\u984c\u306a\u3044\u304c\u3001Elasticsearch\u306f\u5024\u304c\u306a\u3044\u5834\u5408\u3001\u30d5\u30a3\u30fc\u30eb\u30c9\u81ea\u4f53\u304c\u5b58\u5728\u3057\u306a\u3044\u306e\u3067\u3001\u305d\u306e\u3088\u3046\u306a\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u30ea\u30cd\u30fc\u30e0\u3059\u308b\u5834\u5408\u306f\u5fc5\u8981\u306b\u306a\u308b<\/li>\n<\/ul>\n
curl -H 'Content-type: application\/json' -XPOST 'http:\/\/localhost:9200\/_reindex' -d '{\n "source": {\n "index": "warloads_202102"\n },\n "dest": {\n "index": "warloads_202103",\n "pipeline": "warloads_rename_age_to_death_age_pipeline"\n }\n}'<\/code><\/pre>\n
\n\u3082\u3061\u308d\u3093\u4ed6\u306e\u9805\u76ee\u306f\u305d\u306e\u307e\u307e\u3067\u3001match_all<\/code>\u30af\u30a8\u30ea\u3067\u691c\u7d22\u3057\u3066\u3082\u3061\u3083\u3093\u3068\u5168\u9805\u76ee\u30c7\u30fc\u30bf\u304c\u5165\u3063\u3066\u307e\u3057\u305f\u3002<\/p>\n
{\n "warloads_202103": { \/\/ \u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u540d\u304c\u5909\u66f4\u3055\u308c\u3066\u3044\u308b\n "mappings": {\n "properties": {\n "death_age": { \/\/ \u30d5\u30a3\u30fc\u30eb\u30c9\u540d\u304c\u5909\u66f4\u3055\u308c\u3066\u3044\u308b\n "type": "long"\n }\n }\n }\n }\n}<\/code><\/pre>\n
\u30d5\u30a3\u30fc\u30eb\u30c9\u306e\u5b9a\u7fa9\u3092\u5909\u66f4\u3057\u305f\u3044\u3060\u3051\u306e\u30b1\u30fc\u30b9<\/h3>\n
warloads_202102<\/code>\u3068\u3044\u3046\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306b\u304a\u3044\u3066\u3001
\nintroductions<\/code>\u30d5\u30a3\u30fc\u30eb\u30c9\u306e\u30a2\u30ca\u30e9\u30a4\u30b6\u30fc\u3092 \u30c7\u30d5\u30a9\u30eb\u30c8\u306estarndard analyzer<\/a> => kuromoji analyzer<\/a>
\n\u306b\u5909\u66f4\u3059\u308b\u30b1\u30fc\u30b9\u3092\u8003\u3048\u307e\u3059\u3002<\/p>\n{\n "warloads_202102": {\n "mappings": {\n "introduction": {\n "type": "text",\n \/\/ \u3053\u3053\u306b\u3001"analyzer": "kuromoji" \u306e\u8a2d\u5b9a\u3092\u8ffd\u52a0\u3059\u308b\n }\n }\n }\n}<\/code><\/pre>\n
\nkuromoji \u30d7\u30e9\u30b0\u30a4\u30f3\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u304c\u5b8c\u4e86\u3057\u305f\u3089\u3001\u307e\u305a\u306f\u5909\u66f4\u5f8c\u306ewarloads_202103<\/code>\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n
curl -H 'Content-type: application\/json' -XPUT 'http:\/\/localhost:9200\/warloads_202103' -d '{\n "mappings": {\n "properties": {\n "introduction": {\n "type": "text",\n "analyzer": "kuromoji" \/\/ \u30a2\u30ca\u30e9\u30a4\u30b6\u30fc\u306b,kuromoji\u3092\u6307\u5b9a\n },\n \/\/ \u4ed6\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u306f\u7701\u7565\n }\n }\n}'<\/code><\/pre>\n
warloads_202102<\/code>\u304b\u3089
warloads_202103<\/code>\u306b\u30c7\u30fc\u30bf\u3092\u6d41\u3057\u8fbc\u3081\u3070\u5927\u4e08\u592b\u3067\u3059\u3002
\n\u30d5\u30a3\u30fc\u30eb\u30c9\u540d\u304c\u5909\u66f4\u3055\u308c\u306a\u3051\u308c\u3070\u3001\u5358\u7d14\u306b\u65b0\u3057\u3044\u5b9a\u7fa9\u3067\u30c7\u30fc\u30bf\u304c\u30b3\u30d4\u30fc\u3055\u308c\u307e\u3059\u3002<\/p>\ncurl -H 'Content-type: application\/json' -XPOST 'http:\/\/localhost:9200\/_reindex' -d '{\n "source": {\n "index": "warloads_202102"\n },\n "dest": {\n "index": "warloads_202103"\n }\n}'<\/code><\/pre>\n
warloads_202103<\/code>\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306b\u30c7\u30fc\u30bf\u304c\u767b\u9332\u3055\u308c\u307e\u3057\u305f\u3002
\n\u5b9f\u969b\u306bmatch\u691c\u7d22\u3059\u308b\u3068\u3001\u65e5\u672c\u8a9e\u306e\u5358\u8a9e\u3092\u610f\u8b58\u3057\u305f\u691c\u7d22\u304c\u3067\u304d\u3066\u3044\u307e\u3057\u305f\u3002<\/p>\n\u65e2\u5b58\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u304b\u3089\u5c0e\u51fa\u53ef\u80fd\u306a\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u8ffd\u52a0\u3059\u308b\u30b1\u30fc\u30b9<\/h2>\n
warloads_202102<\/code>\u3068\u3044\u3046\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306b\u304a\u3044\u3066\u3001
\nintroduction<\/code>\u3068\u3044\u3046\u30d5\u30a3\u30fc\u30eb\u30c9\u304b\u3089\u305d\u306e\u6587\u5b57\u9577\u3092\u5c0e\u51fa\u3057\u3001
introduction_length<\/code>\u3068\u3044\u3046\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u8ffd\u52a0\u3059\u308b\u30b1\u30fc\u30b9\u3092\u8003\u3048\u307e\u3059\u3002<\/p>\n
{\n "warloads_202102": {\n "mappings": {\n "introduction": {\n "type": "text",\n },\n \/\/ \u4ee5\u4e0b\u3092\u8ffd\u52a0\u3059\u308b\n \/\/ "introduction_length": {\n \/\/ "type": "long",\n \/\/ }\n }\n }\n}<\/code><\/pre>\n
warloads_202103<\/code>\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n
curl -H 'Content-type: application\/json' -XPUT 'http:\/\/localhost:9200\/warloads_202103' -d '{\n "mappings": {\n "properties": {\n "introduction_length": {\n "type": "long"\n },\n \/\/ \u4ed6\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u306f\u7701\u7565\n }\n }\n}'<\/code><\/pre>\n
curl -H 'Content-type: application\/json' -XPUT 'http:\/\/localhost:9200\/_ingest\/pipeline\/warloads_introcuce_set_pipeline' -d '{\n "processors": [\n {\n "set": {\n "field": "introduction_length",\n "copy_from": "introduction"\n }\n }\n ]\n}'<\/code><\/pre>\n
\n
field<\/code>\u3067\u8a2d\u5b9a\u5148\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u540d\u3092\u3001
copy_from<\/code>\u3067\u30b3\u30d4\u30fc\u5143\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u540d\u3092\u6307\u5b9a\u3059\u308b<\/li>\n<\/ul>\n
warloads_202102<\/code>\u304b\u3089
warloads_202103<\/code>\u306b\u30c7\u30fc\u30bf\u3092\u6d41\u3057\u8fbc\u3081\u3070\u5927\u4e08\u592b\u3067\u3059\u3002<\/p>\n
curl -H 'Content-type: application\/json' -XPOST 'http:\/\/localhost:9200\/_reindex' -d '{\n "source": {\n "index": "warloads_202102"\n },\n "dest": {\n "index": "warloads_202103"\n }\n}'<\/code><\/pre>\n
warloads_202103<\/code>\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306b\u30c7\u30fc\u30bf\u304c\u767b\u9332\u3055\u308c\u307e\u3057\u305f\u3002
\n\u5b9f\u969b\u306bmatch\u691c\u7d22\u3059\u308b\u3068\u3001\u65e5\u672c\u8a9e\u306e\u5358\u8a9e\u3092\u610f\u8b58\u3057\u305f\u691c\u7d22\u304c\u3067\u304d\u3066\u3044\u307e\u3057\u305f\u3002<\/p>\n\u30cf\u30a4\u30e9\u30a4\u30c8<\/h2>\n
\nhttps:\/\/www.elastic.co\/guide\/en\/elasticsearch\/reference\/7.11\/highlighting.html<\/a><\/p>\nwarloads<\/code> \u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306e
introduction<\/code> \u306b\u5bfe\u3057\u3066\u691c\u7d22\u3057\u3066\u3001\u691c\u7d22\u7d50\u679c\u3092\u30cf\u30a4\u30e9\u30a4\u30c8\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n
introduction<\/code>\u3092
\u6226\u56fd\u6642\u4ee3<\/code>\u3067\u691c\u7d22\u3057\u3066\u3001\u7d50\u679c\u3092\u30cf\u30a4\u30e9\u30a4\u30c8\u3057\u3066\u3044\u307e\u3059\u3002
\n\u30aa\u30d7\u30b7\u30e7\u30f3\u306f\u8272\u3005\u3042\u308a\u307e\u3059\u304c\u3001fragment_size<\/code>\u306e\u8a2d\u5b9a\u3060\u3051\u884c\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n
curl -H 'Content-type: application\/json' -XPOST 'http:\/\/localhost:9200\/warloads\/_search' -d '{\n "query": {\n "match": {\n "introduction": "\u6226\u56fd\u6642\u4ee3"\n }\n },\n "highlight": {\n "fields": [\n {\n "introduction": {}\n }\n ],\n "fragment_size": 10\n }\n}'<\/code><\/pre>\n
"highlight": {\n "introduction": [\n "\u65e7\u5b57\u4f53\uff1a\u5fb7\u5ddd \u5bb6\u5eb7\uff09\u306f\u3001<em>\u6226\u56fd<\/em><em>\u6642\u4ee3<\/em>",\n "\u304b\u3089\u6c5f\u6238<em>\u6642\u4ee3<\/em>\u521d\u671f\u306b\u304b\u3051\u3066\u306e",\n "\u6b66\u5c06\u30fb<em>\u6226\u56fd<\/em>\u5927\u540d[1]\u30fb",\n "<em>\u6226\u56fd<\/em><em>\u6642\u4ee3<\/em>\u306b\u7d42\u6b62\u7b26\u3092\u6253\u3061"\n ]\n}<\/code><\/pre>\n
\n
<em>\u6226\u56fd<\/em><\/code>\u30fb
<em>\u6642\u4ee3<\/em><\/code>\u306e\u3088\u3046\u306b\u5bfe\u8c61\u306e\u30c8\u30fc\u30af\u30f3\u304c
<em><\/code>\u30bf\u30b0\u3067\u56f2\u307e\u308c\u308b<\/li>\n<\/ul>\n
<em><\/code>\u30bf\u30b0\u3067\u5f37\u8abf\u3057\u3066\u304f\u308c\u305f\u65b9\u304c\u5b09\u3057\u3044\u3067\u3059\u3002
\n\u305d\u306e\u3088\u3046\u306a\u5834\u5408\u306f\u3001"number_of_fragments": 0<\/code> \u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u8ffd\u52a0\u3059\u308b\u3053\u3068\u3067\u3001\u30d5\u30e9\u30b0\u30e1\u30f3\u30c8\u5206\u3051\u3055\u308c\u305a\u306b\u7d50\u679c\u304c\u8fd4\u5374\u3055\u308c\u307e\u3059\u3002<\/p>\n
"highlight": {\n "introduction": [\n "\u5fb3\u5ddd \u5bb6\u5eb7\uff08\u3068\u304f\u304c\u308f \u3044\u3048\u3084\u3059\u3001\u65e7\u5b57\u4f53\uff1a\u5fb7\u5ddd \u5bb6\u5eb7\uff09\u306f\u3001<em>\u6226\u56fd<\/em><em>\u6642\u4ee3<\/em>\u304b\u3089\u6c5f\u6238<em>\u6642\u4ee3<\/em>\u521d\u671f\u306b\u304b\u3051\u3066\u306e\u6b66\u5c06\u30fb<em>\u6226\u56fd<\/em>\u5927\u540d[1]\u30fb\u5929\u4e0b\u4eba\u3002\u5b89\u7965\u677e\u5e73\u5bb69\u4ee3\u5f53\u4e3b\u3067\u5fb3\u5ddd\u5bb6\u3084\u5fb3\u5ddd\u5c06\u8ecd\u5bb6\u3001\u5fa1\u4e09\u5bb6\u306e\u59cb\u7956\u3002\u65e7\u79f0\u306f\u677e\u5e73 \u5143\u5eb7\uff08\u307e\u3064\u3060\u3044\u3089 \u3082\u3068\u3084\u3059\uff09\u3002<em>\u6226\u56fd<\/em><em>\u6642\u4ee3<\/em>\u306b\u7d42\u6b62\u7b26\u3092\u6253\u3061\u3001\u671d\u5ef7\u3088\u308a\u5f81\u5937\u5927\u5c06\u8ecd\u306b\u4efb\u305b\u3089\u308c\u30011603\u5e74\u3001260\u5e74\u9593\u7d9a\u304f\u6c5f\u6238\u5e55\u5e9c\u3092\u958b\u3044\u305f[1]\u3002\u4e09\u82f1\u5091\u306e\u3072\u3068\u308a\u3067\u3042\u308b\u3002"\n ]\n}<\/code><\/pre>\n
\u96c6\u8a08<\/h2>\n
\nhttps:\/\/www.elastic.co\/guide\/en\/elasticsearch\/reference\/7.11\/search-aggregations.html<\/a><\/p>\n\n
\n
group by<\/code>\u306b\u76f8\u5f53\u3059\u308b<\/li>\n<\/ul>\n<\/li>\n
\n
\n
\u30e1\u30c8\u30ea\u30c3\u30af\u96c6\u8a08\u306e\u4f8b\uff08Sum, Average\uff09<\/h3>\n
age<\/code>\u306e\u5408\u8a08\u3068\u5e73\u5747\u3092\u53d6\u5f97\u3059\u308b\u96c6\u8a08\u65b9\u6cd5\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n
curl -H 'Content-type: application\/json' -XPOST 'http:\/\/localhost:9200\/warloads\/_search' -d '{\n "size": 0,\n "aggs": {\n "age_sum": {\n "sum": {\n "field": "age"\n }\n },\n "age_avg": {\n "avg": {\n "field": "age"\n }\n }\n }\n}'<\/code><\/pre>\n
{\n "aggregations": {\n "age_sum": {\n "value": 177\n },\n "age_avg": {\n "value": 59\n }\n }\n}<\/code><\/pre>\n
\u30d0\u30b1\u30c3\u30c8\u96c6\u8a08\u306e\u4f8b\uff08Terms, Range\uff09<\/h3>\n
\n
\n
ranges<\/code>\u3067
age<\/code>\u30923\u6bb5\u968e\uff0850\u672a\u6e80\u300150\u4ee5\u4e0a70\u672a\u6e80\u300170\u4ee5\u4e0a\uff09\u3067\u7bc4\u56f2\u6307\u5b9a<\/li>\n<\/ul>\n<\/li>\n
\n
introduction<\/code> \u306b\u73fe\u308c\u308b\u5358\u8a9e\u983b\u5ea6\u3092\u6307\u5b9a<\/li>\n
introduction<\/code> \u306f
text<\/code>\u578b\u306e\u305f\u3081\u3001\u96c6\u8a08\u3067\u304d\u306a\u304b\u3063\u305f\u306e\u3067\u3001
fielddata: true<\/code> \u3092\u6307\u5b9a\u3057\u3066\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u518d\u4f5c\u6210\u3059\u308b\u3053\u3068\u3067\u96c6\u8a08\u53ef\u80fd\u306b\u3057\u305f<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n
curl -H 'Content-type: application\/json' -XPOST 'http:\/\/localhost:9200\/warloads\/_search' -d '{\n "size": 0,\n "aggs": {\n "age_range": {\n "range": {\n "field": "age",\n "ranges": [\n { "to": 50 },\n { "from": 50, "to": 70 },\n { "from": 70 }\n ]\n }\n },\n "introduction_terms": {\n "terms": {\n "field": "introduction"\n }\n }\n }\n}'<\/code><\/pre>\n
{\n "aggregations": {\n "age_range": {\n "buckets": [\n {\n "key": "*-50.0",\n "to": 50,\n "doc_count": 1\n },\n {\n "key": "50.0-70.0",\n "from": 50,\n "to": 70,\n "doc_count": 1\n },\n {\n "key": "70.0-*",\n "from": 70,\n "doc_count": 1\n }\n ]\n },\n "introduction_terms": {\n "doc_count_error_upper_bound": 0,\n "sum_other_doc_count": 98,\n "buckets": [\n {\n "key": "\u4e09",\n "doc_count": 3\n },\n {\n "key": "\u5927\u540d",\n "doc_count": 3\n },\n {\n "key": "\u5e74",\n "doc_count": 3\n },\n {\n "key": "\u6226\u56fd",\n "doc_count": 3\n },\n {\n "key": "\u6642\u4ee3",\n "doc_count": 3\n },\n {\n "key": "\u6b66\u5c06",\n "doc_count": 3\n },\n {\n "key": "10",\n "doc_count": 2\n },\n {\n "key": "\u306e\u3076",\n "doc_count": 2\n },\n {\n "key": "\u4eba",\n "doc_count": 2\n },\n {\n "key": "\u4ee3",\n "doc_count": 2\n }\n ]\n }\n }\n}<\/code><\/pre>\n
\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u96c6\u8a08<\/h2>\n
\n\u30d0\u30b1\u30c3\u30c8\u96c6\u8a08=>\u30d0\u30b1\u30c3\u30c8\u96c6\u8a08=>...=>\u30e1\u30c8\u30ea\u30c3\u30af\u96c6\u8a08\u306e\u3088\u3046\u306b\u3001\u96c6\u8a08\u3092\u4f55\u968e\u5c64\u3082\u91cd\u306d\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n
\n\u8a95\u751f\u65e5\u3067\u30d0\u30b1\u30c3\u30c8\u96c6\u8a08\uff08date_histogram\uff09 => \u540d\u524d\u3067\u30d0\u30b1\u30c3\u30c8\u96c6\u8a08\uff08terms\uff09 => \u5e74\u9f62\u3067\u30e1\u30c8\u30ea\u30c3\u30af\u96c6\u8a08\uff08avg\uff09
\n\u3068\u3044\u3046\u96c6\u8a08\u3092\u3084\u3063\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\ncurl -H 'Content-type: application\/json' -XPOST 'http:\/\/localhost:9200\/warloads\/_search' -d '{\n "query": {\n "match_all": {}\n },\n "aggs": {\n "group_by_birthday": {\n "date_histogram": {\n "field": "birthday",\n "calendar_interval": "year",\n "min_doc_count": 1\n },\n "aggs": {\n "group_by_name": {\n "terms": {\n "field": "name"\n },\n "aggs": {\n "average_age": {\n "avg": {\n "field": "age"\n }\n }\n }\n }\n }\n }\n }\n}'<\/code><\/pre>\n
\n\u5206\u304b\u308a\u306b\u304f\u3044\u3067\u3059\u304c\u3001\u3061\u3083\u3093\u3068\u96c6\u8a08\u3067\u304d\u3066\u3044\u307e\u3059\u3002<\/p>\n"aggregations": { - \n "group_by_birthday": { - \n "buckets": [ - \n { - \n "key_as_string": "1523-01-01",\n "key": -14106009600000,\n "doc_count": 1,\n "group_by_name": { - \n "doc_count_error_upper_bound": 0,\n "sum_other_doc_count": 0,\n "buckets": [ - \n { - \n "key": "\u6b66\u7530\u3000\u4fe1\u7384",\n "doc_count": 1,\n "average_age": { - \n "value": 53\n }\n }\n ]\n }\n },\n { - \n "key_as_string": "1534-01-01",\n "key": -13758854400000,\n "doc_count": 1,\n "group_by_name": { - \n "doc_count_error_upper_bound": 0,\n "sum_other_doc_count": 0,\n "buckets": [ - \n { - \n "key": "\u7e54\u7530\u3000\u4fe1\u9577",\n "doc_count": 1,\n "average_age": { - \n "value": 49\n }\n }\n ]\n }\n },\n { - \n "key_as_string": "1543-01-01",\n "key": -13474857600000,\n "doc_count": 1,\n "group_by_name": { - \n "doc_count_error_upper_bound": 0,\n "sum_other_doc_count": 0,\n "buckets": [ - \n { - \n "key": "\u5fb3\u5ddd\u3000\u5bb6\u5eb7",\n "doc_count": 1,\n "average_age": { - \n "value": 75\n }\n }\n ]\n }\n }\n ]\n }\n}<\/code><\/pre>\n
\u30d7\u30e9\u30b0\u30a4\u30f3\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h2>\n
\ndocker-compose \u3092\u4f7f\u3063\u3066 Elasticsearch \u3092\u8d77\u52d5\u3059\u308b\u30b1\u30fc\u30b9\u3092\u8a18\u8f09\u3057\u307e\u3059\u3002<\/p>\nFROM docker.elastic.co\/elasticsearch\/elasticsearch:7.11.0\nRUN elasticsearch-plugin install analysis-kuromoji<\/code><\/pre>\n
\n\u30d5\u30a1\u30a4\u30eb\u5168\u4f53\u306f\u3053\u3061\u3089<\/a>\u3092\u53c2\u7167\u304f\u3060\u3055\u3044\u3002<\/p>\nversion: '2.2'\nservices:\n es01:\n # image: docker.elastic.co\/elasticsearch\/elasticsearch:7.11.0 \u65e2\u5b58\u306e\u30a4\u30e1\u30fc\u30b8\u306f\u5229\u7528\u3057\u306a\u3044\n build: . # \u76f4\u4e0b\u306b\u3042\u308bDockerfile\u3092\u5143\u306b\u30a4\u30e1\u30fc\u30b8\u3092\u30d3\u30eb\u30c9\u3057\u3066\u5229\u7528\u3059\u308b\u3088\u3046\u8a2d\u5b9a<\/code><\/pre>\n
docker-compose up<\/code><\/pre>\n
\u3055\u3044\u3054\u306b<\/h2>\n
\n\u4eca\u56de\u3042\u308b\u7a0b\u5ea6\u7406\u89e3\u3067\u304d\u305f\u6c17\u304c\u3059\u308b\u306e\u3067\u3088\u304b\u3063\u305f\u3067\u3059\u3002<\/p>\n
\nhttps:\/\/github.com\/rinoguchi\/elasticsearch_sample<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"