{"id":541,"date":"2021-02-14T19:13:59","date_gmt":"2021-02-14T10:13:59","guid":{"rendered":"http:\/\/localhost:8000\/?p=541"},"modified":"2021-04-05T13:29:50","modified_gmt":"2021-04-05T04:29:50","slug":"elasticsearch","status":"publish","type":"post","link":"http:\/\/localhost:8000\/2021\/02\/elasticsearch.html","title":{"rendered":"Elasticsearch\u306e\u4f7f\u3044\u65b9"},"content":{"rendered":"
\u696d\u52d9\u3067 Elasticsearch<\/a> \u3092\u89e6\u308b\u3053\u3068\u306b\u306a\u3063\u305f\u306e\u3067\u3001\u591a\u5c11\u4eca\u66f4\u611f\u3042\u308a\u307e\u3059\u304c\u3001\u74b0\u5883\u69cb\u7bc9\u30fb\u30c7\u30fc\u30bf\u767b\u9332\u30fb\u30de\u30c3\u30d4\u30f3\u30b0\u5b9a\u7fa9\u30fb\u691c\u7d22\u306a\u3069\u3001\u4e00\u901a\u308a\u306e\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9\u3092\u8a66\u3057\u3066\u307f\u3088\u3046\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n Elasticsearch version: 7.11<\/p>\n \u4ee5\u4e0b\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3092\u5143\u306b\u3001Docker\u3092\u4f7f\u3063\u3066Elasticsearch\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3088\u3046\u3068\u601d\u3044\u307e\u3059\u3002 \u307e\u305a\u306f\u3001docker-compose.yml\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002 \u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n Docker\u30a8\u30f3\u30b8\u30f3\u306e\u30e1\u30e2\u30ea\u5272\u308a\u5f53\u3066\u304c\u8db3\u308a\u306a\u3044\u3068 \u78ba\u8a8d\u3057\u305f\u3068\u3053\u308d\u554f\u984c\u306a\u304f\u52d5\u3044\u3066\u3044\u308b\u3088\u3046\u3067\u3059\u3002<\/p>\n \u7ba1\u7406\u30c4\u30fc\u30eb\u3068\u3057\u3066Celebro<\/a>\u3092\u5c0e\u5165\u3057\u3088\u3046\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n services\u306bcerebro\u306e\u5b9a\u7fa9\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002 \u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n \u30d6\u30e9\u30a6\u30b6\u3067\u3001 http:\/\/localhost:9000<\/a> \u306b\u30a2\u30af\u30bb\u30b9\u3057\u3066\u3001Node Address \u306b Connect\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u3001Cerebro\u306e\u7ba1\u7406\u753b\u9762\u304c\u7acb\u3061\u4e0a\u304c\u308a\u307e\u3059\u3002 Cerebro\u306erest\u753b\u9762\u304b\u3089API\u3092\u5b9f\u884c\u3057\u3066\u3001\u30c7\u30fc\u30bf\u3092\u767b\u9332\u3057\u307e\u3057\u305f\u3002\uff08\u672c\u8a18\u4e8b\u3067\u306fcurl\u5f62\u5f0f\u3067\u8a18\u8f09\u3057\u307e\u3059\uff09 \u6226\u56fd\u6b66\u5c063\u4eba\uff08 \u7279\u306b\u4e8b\u524d\u6e96\u5099\u306f\u5fc5\u8981\u306a\u304f\u3001document\uff08\u30c7\u30fc\u30bf\uff09\u3092\u6295\u5165\u3059\u308b\u3068\u3001\u81ea\u52d5\u7684\u306bindex\uff08RDB\u306b\u304a\u3051\u308b\u30c6\u30fc\u30d6\u30eb\u306b\u76f8\u5f53\uff09\u3068\u30de\u30c3\u30d4\u30f3\u30b0\u5b9a\u7fa9\uff08document\u304a\u3088\u3073field\u304c\u3069\u3046\u4fdd\u5b58\u3055\u308c\u3001\u3069\u3046\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3055\u308c\u308b\u304b\uff09\u304c\u4f5c\u6210\u3055\u308c\u307e\u3059\u3002<\/p>\n \u4eca\u56de\u3001\u81ea\u52d5\u3067\u4f5c\u6210\u3055\u308c\u305f\u30de\u30c3\u30d4\u30f3\u30b0\u5b9a\u7fa9\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n \u81ea\u52d5\u3067\u4f5c\u6210\u3055\u308c\u305f\u30de\u30c3\u30d4\u30f3\u30b0\u5b9a\u7fa9\u306f\u6b8b\u5ff5\u306a\u304c\u3089\u671f\u5f85\u901a\u308a\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3067\u3057\u305f\u3002<\/p>\n\u74b0\u5883\u69cb\u7bc9<\/h2>\n
\nhttps:\/\/www.elastic.co\/guide\/en\/elasticsearch\/reference\/7.11\/docker.html<\/a><\/p>\ndocker-compose.yml\u3092\u4f5c\u6210<\/h3>\n
\n\u3068\u308a\u3042\u3048\u305a\u306f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306e\u5185\u5bb9\u3092\u305d\u306e\u307e\u307e\u30b3\u30d4\u30fc\u3067OK\u3060\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\nversion: '2.2'\nservices:\n es01:\n image: docker.elastic.co\/elasticsearch\/elasticsearch:7.11.0\n container_name: es01\n environment:\n - node.name=es01\n - cluster.name=es-docker-cluster\n - discovery.seed_hosts=es02,es03\n - cluster.initial_master_nodes=es01,es02,es03\n - bootstrap.memory_lock=true\n - "ES_JAVA_OPTS=-Xms512m -Xmx512m"\n ulimits:\n memlock:\n soft: -1\n hard: -1\n volumes:\n - data01:\/usr\/share\/elasticsearch\/data\n ports:\n - 9200:9200\n networks:\n - elastic\n es02:\n image: docker.elastic.co\/elasticsearch\/elasticsearch:7.11.0\n container_name: es02\n environment:\n - node.name=es02\n - cluster.name=es-docker-cluster\n - discovery.seed_hosts=es01,es03\n - cluster.initial_master_nodes=es01,es02,es03\n - bootstrap.memory_lock=true\n - "ES_JAVA_OPTS=-Xms512m -Xmx512m"\n ulimits:\n memlock:\n soft: -1\n hard: -1\n volumes:\n - data02:\/usr\/share\/elasticsearch\/data\n networks:\n - elastic\n es03:\n image: docker.elastic.co\/elasticsearch\/elasticsearch:7.11.0\n container_name: es03\n environment:\n - node.name=es03\n - cluster.name=es-docker-cluster\n - discovery.seed_hosts=es01,es02\n - cluster.initial_master_nodes=es01,es02,es03\n - bootstrap.memory_lock=true\n - "ES_JAVA_OPTS=-Xms512m -Xmx512m"\n ulimits:\n memlock:\n soft: -1\n hard: -1\n volumes:\n - data03:\/usr\/share\/elasticsearch\/data\n networks:\n - elastic\n\nvolumes:\n data01:\n driver: local\n data02:\n driver: local\n data03:\n driver: local\n\nnetworks:\n elastic:\n driver: bridge<\/code><\/pre>\n
\u5b9f\u884c\u3068\u78ba\u8a8d<\/h3>\n
docker-compose up<\/code><\/pre>\n
Exit 137<\/code>\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3059\u308b\u3068\u601d\u3044\u307e\u3059\u3002
\n4GB\u7a0b\u5ea6\u306f\u5272\u308a\u5f53\u3066\u308b\u3068\u554f\u984c\u306a\u3044\u3088\u3046\u3067\u3059\u3002\uff08\u81ea\u5206\u306f5GB\u5272\u308a\u5f53\u3066\u3066\u307e\u3059\uff09<\/p>\ncurl -X GET "localhost:9200\/_cat\/nodes?v=true&pretty"\n\nip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name\n172.18.0.4 43 93 7 0.28 0.62 0.43 cdhilmrstw - es03\n172.18.0.3 45 93 7 0.28 0.62 0.43 cdhilmrstw - es01\n172.18.0.2 58 93 7 0.28 0.62 0.43 cdhilmrstw * es02<\/code><\/pre>\n
Cerebro\uff08\u7ba1\u7406\u30c4\u30fc\u30eb\uff09\u306e\u5c0e\u5165<\/h2>\n
docker-compose.yml\u306b\u8ffd\u8a18<\/h3>\n
\n\u30dd\u30a4\u30f3\u30c8\u306f\u30019000\u756a\u30dd\u30fc\u30c8\u3092\u9732\u51fa\u3059\u308b\u3068\u3053\u308d\u3050\u3089\u3044\u3067\u3059\u3002<\/p>\nservices:\n # ===== \u3053\u3053\u304b\u3089 =====\n cerebro:\n image: lmenezes\/cerebro:0.9.3\n ports:\n - 9000:9000\n # ===== \u3053\u3053\u307e\u3067 =====\n es01:\n image: docker.elastic.co\/elasticsearch\/elasticsearch:7.11.0<\/code><\/pre>\n
\u5b9f\u884c\u3068\u78ba\u8a8d<\/h3>\n
docker-compose up<\/code><\/pre>\n
http:\/\/host.docker.internal:9200<\/code> \u3092\u6307\u5b9a\u3057\u307e\u3059\u3002
\n\u3061\u306a\u307f\u306b\u3001host.docker.internal<\/code>\u306fDocker\u30b3\u30f3\u30c6\u30ca\u5185\u304b\u3089\u30db\u30b9\u30c8OS\u306e\u30db\u30b9\u30c8\u540d\u3092\u6307\u3057\u307e\u3059\u3002
\n<\/p>\n
\n\u3053\u3053\u3067\u306f\u3001REST API\u306e\u5b9f\u884c\u3084INDEX\u5b9a\u7fa9\u306e\u78ba\u8a8d\u306a\u3069\u3092\u3084\u3063\u3066\u3044\u304f\u3053\u3068\u306b\u306a\u308b\u3068\u601d\u3044\u307e\u3059\u3002
\n<\/p>\n\u30c7\u30fc\u30bf\uff08document\uff09\u767b\u9332<\/h2>\n
\n<\/p>\n\u7e54\u7530\u4fe1\u9577<\/code>\u30fb
\u5fb3\u5ddd\u5bb6\u5eb7<\/code>\u30fb
\u6b66\u7530\u4fe1\u7384<\/code>\uff09\u306e\u30c7\u30fc\u30bf\u3092\u767b\u9332\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n
curl -H 'Content-type: application\/json' -XPUT 'http:\/\/localhost:9200\/warloads\/_doc\/1' -d '{\n "name": "\u7e54\u7530\u3000\u4fe1\u9577",\n "countries": ["\u5c3e\u5f35", "\u7f8e\u6fc3", "\u4f0a\u52e2", "\u6442\u6d25", "\u6cb3\u5185", "\u5927\u548c"],\n "introduction": "\u7e54\u7530 \u4fe1\u9577\uff08\u304a\u3060 \u306e\u3076\u306a\u304c\u3001\u5929\u65873\u5e745\u670812\u65e5\u30081534\u5e746\u670823\u65e5\u3009 - \u5929\u6b6310\u5e746\u67082\u65e5\u30081582\u5e746\u670821\u65e5\u3009\uff09\u306f\u3001\u65e5\u672c\u306e\u6226\u56fd\u6642\u4ee3\u304b\u3089\u5b89\u571f\u6843\u5c71\u6642\u4ee3\u306b\u304b\u3051\u3066\u306e\u6b66\u5c06\u3001\u6226\u56fd\u5927\u540d\u3002\u4e09\u82f1\u5091\u306e\u4e00\u4eba\u3002",\n "birthday": "1534-06-23",\n "age": 49\n}'\n\ncurl -H 'Content-type: application\/json' -XPUT 'http:\/\/localhost:9200\/warloads\/_doc\/2' -d '{\n "name": "\u5fb3\u5ddd\u3000\u5bb6\u5eb7",\n "countries": ["\u4e09\u6cb3"],\n "introduction": "\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\u6226\u56fd\u6642\u4ee3\u304b\u3089\u6c5f\u6238\u6642\u4ee3\u521d\u671f\u306b\u304b\u3051\u3066\u306e\u6b66\u5c06\u30fb\u6226\u56fd\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\u6226\u56fd\u6642\u4ee3\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 "birthday": "1543-01-31",\n "age": 75\n}'\n\ncurl -H 'Content-type: application\/json' -XPUT 'http:\/\/localhost:9200\/warloads\/_doc\/3' -d '{\n "name": "\u6b66\u7530\u3000\u4fe1\u7384",\n "countries": ["\u7532\u6590", "\u4fe1\u6fc3", "\u99ff\u6cb3", "\u98db\u9a28"],\n "introduction": "\u6b66\u7530 \u4fe1\u7384\uff08\u305f\u3051\u3060 \u3057\u3093\u3052\u3093\uff09 \/ \u6b66\u7530 \u6674\u4fe1\uff08\u305f\u3051\u3060 \u306f\u308b\u306e\u3076\uff09\u306f\u3001\u6226\u56fd\u6642\u4ee3\u306e\u6b66\u5c06\u3001\u7532\u6590\u306e\u5b88\u8b77\u5927\u540d\u30fb\u6226\u56fd\u5927\u540d\u3002\u7532\u6590\u6e90\u6c0f\u306e\u5ae1\u6d41\u306b\u3042\u305f\u308b\u7532\u6590\u6b66\u7530\u5bb6\u7b2c19\u4ee3\u5f53\u4e3b\u3002\u8af1\u306f\u6674\u4fe1\u3001\u901a\u79f0\u306f\u592a\u90ce\uff08\u305f\u308d\u3046\uff09\u3002\u59d3\u540d\u306f\u6e90\u6674\u4fe1 \u300c\u4fe1\u7384\u300d\u3068\u306f\uff08\u51fa\u5bb6\u5f8c\u306e\uff09\u6cd5\u540d\u3067\u3001\u6b63\u5f0f\u306b\u306f\u5fb3\u6804\u8ed2\u4fe1\u7384\u30021915\u5e74\uff08\u5927\u6b634\u5e74\uff0911\u670810\u65e5\u306b\u5f93\u4e09\u4f4d\u3092\u8d08\u3089\u308c\u308b",\n "birthday": "1523-11-03",\n "age": 53\n}'<\/code><\/pre>\n
{\n "warloads": {\n "mappings": {\n "properties": {\n "age": {\n "type": "long"\n },\n "birthday": {\n "type": "text",\n "fields": { \n "keyword": {\n "type": "keyword",\n "ignore_above": 256\n }\n }\n },\n "countries": {\n "type": "text",\n "fields": {\n "keyword": {\n "type": "keyword",\n "ignore_above": 256\n }\n }\n },\n "introduction": {\n "type": "text",\n "fields": {\n "keyword": {\n "type": "keyword",\n "ignore_above": 256\n }\n }\n },\n "name": {\n "type": "text",\n "fields": {\n "keyword": {\n "type": "keyword",\n "ignore_above": 256\n }\n }\n }\n }\n }\n }\n}<\/code><\/pre>\n