{"id":1511,"date":"2022-04-20T22:20:10","date_gmt":"2022-04-20T14:20:10","guid":{"rendered":"https:\/\/www.buyao007.icu\/?p=1511"},"modified":"2022-05-01T19:07:46","modified_gmt":"2022-05-01T11:07:46","slug":"1","status":"publish","type":"post","link":"https:\/\/www.buyao007.icu\/?p=1511","title":{"rendered":"1.Elasticsearch\u5feb\u901f\u5165\u95e8"},"content":{"rendered":"\n<p>\u5b59\u5bcc\u9633\uff0c \u6c5f\u6e56\u4eba\u79f0\u6ca1\u4eba\u79f0\u3002\u591a\u5e74\u4e92\u8054\u7f51\u8fd0\u7ef4\u5de5\u4f5c\u7ecf\u9a8c\uff0c\u66fe\u8d1f\u8d23\u8fc7\u5b59\u5e03\u65af\u5927\u89c4\u6a21\u96c6\u7fa4\u67b6\u6784\u81ea\u52a8\u5316\u8fd0\u7ef4\u7ba1\u7406\u5de5\u4f5c\u3002\u64c5\u957fWeb\u96c6\u7fa4\u67b6\u6784\u4e0e\u81ea\u52a8\u5316\u8fd0\u7ef4\uff0c\u66fe\u8d1f\u8d23\u56fd\u5185\u67d0\u5927\u578b\u535a\u5ba2\u7f51\u7ad9\u8fd0\u7ef4\u5de5\u4f5c\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc_0\">1.Elasticsearch\u4ecb\u7ecd<\/h2>\n\n\n\n<p><strong><em>1.\u4ec0\u4e48\u662fLucene<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Lucene\u662f\u4e00\u4e2a\u9ad8\u6027\u80fd\u7684java\u641c\u7d22\u5f15\u64ce\u5e93,\u64cd\u4f5c\u975e\u5e38\u7e41\u7410\uff0c\u9700\u8981\u5177\u5907java\u5f00\u53d1\u7ecf\u9a8c\u3002 Elasticsearch\u662f\u57fa\u4e8eLucene\u4e4b\u4e0a\u5305\u88c5\u4e00\u5c42\u5916\u58f3\uff0c\u5c4f\u853d\u4e86Lucene\u7684\u590d\u6742\u64cd\u4f5c\uff0c\u5373\u4f7f\u4e0d\u4f1ajava\u8bed\u8a00\u4e5f\u53ef\u4ee5\u5feb\u901f\u4e0a\u624b\u3002<\/code><\/pre>\n\n\n\n<p><strong><em>2.\u4ec0\u4e48\u662f\u5168\u6587\u68c0\u7d22\u548c\u5012\u6392\u7d22\u5f15<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u5efa\u8bae\u53c2\u8003\u4e0b\u65b9\u94fe\u63a5\uff1a\r\nhttps:&#47;&#47;www.cnblogs.com\/zhaoshaopeng\/p\/12876111.html\r<\/code><\/pre>\n\n\n\n<p>\u4ec0\u4e48\u662f\u7d22\u5f15<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u7d22\u5f15\u5c31\u597d\u6bd4\u4e66\u7684\u76ee\u5f55\uff0c\u5982\u679c\u6211\u4eec\u60f3\u5feb\u901f\u67e5\u770b\u67d0\u4e2a\u7ae0\u8282\uff0c\u53ea\u9700\u8981\u627e\u5230\u76ee\u5f55\u91cc\u76f8\u5e94\u7ae0\u8282\u5bf9\u5e94\u7684\u9875\u6570\u5373\u53ef\u3002\r\n\u901a\u8fc7\u76ee\u5f55\u627e\u5230\u7ae0\u8282\uff0c\u901a\u8fc7\u7ae0\u8282\u627e\u5230\u9875\u7801\u8fd9\u4e2a\u8fc7\u7a0b\u5c31\u662f\u7d22\u5f15\u7684\u8fc7\u7a0b\u3002\r\n\u7d22\u5f15\u7684\u76ee\u7684\u5c31\u662f\u52a0\u5feb\u6570\u636e\u641c\u7d22\u7684\u6548\u7387\r<\/code><\/pre>\n\n\n\n<p>\u4ec0\u4e48\u662f\u5168\u6587\u68c0\u7d22<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u5148\u5efa\u7acb\u7d22\u5f15\uff0c\u518d\u5bf9\u7d22\u5f15\u8fdb\u884c\u641c\u7d22\u7684\u8fc7\u7a0b\u5c31\u53eb\u5168\u6587\u68c0\u7d22(Full-text Search)\u3002\r\n\u4f8b\u5982\u8ba9\u4f60\u80cc\u4e00\u9996\u8bd7\uff0c\u8bd7\u7684\u540d\u5b57\u53eb\u9759\u591c\u601d\uff0c\u90a3\u4e48\u9759\u591c\u601d\u5c31\u662f\u7d22\u5f15\u3002\r\n\u4ee5\u4e0b\u56fe\u7247\u5c31\u662f\u4e00\u4e2a\u5168\u6587\u7d22\u5f15\uff0c\u4e5f\u53eb\u6b63\u5411\u7d22\u5f15\r<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-102.png\" alt=\"\" class=\"wp-image-1515\" width=\"611\" height=\"301\" srcset=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-102.png 865w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-102-300x148.png 300w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-102-768x379.png 768w\" sizes=\"(max-width: 611px) 100vw, 611px\" \/><\/figure>\n\n\n\n<p>\u4ec0\u4e48\u662f\u5012\u6392\u7d22\u5f15<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u7d22\u5f15\u662f\u6839\u636e\u7ae0\u8282\u627e\u5230\u9875\u6570\uff0c\u4f46\u662f\u5982\u679c\u6211\u5e76\u4e0d\u77e5\u9053\u6211\u8981\u627e\u7684\u5185\u5bb9\u5c5e\u4e8e\u54ea\u4e2a\u7ae0\u8282\uff0c\u6bd4\u5982\u6211\u53ea\u77e5\u9053\u4e00\u4e2a\u5173\u952e\u8bcd\uff0c\u4f46\u662f\u4e0d\u77e5\u9053\u8fd9\u4e2a\u5173\u952e\u8bcd\u5c5e\u4e8e\u54ea\u4e2a\u7ae0\u8282\u3002\r\n\u5927\u5bb6\u53ef\u4ee5\u60f3\u4e00\u4e0b\uff0c\u6211\u4eec\u5e73\u65f6\u5229\u7528\u641c\u7d22\u5f15\u64ce\u641c\u7d22\u7684\u65f6\u5019\u662f\u4e0d\u662f\u4e5f\u662f\u8fd9\u79cd\u573a\u666f\u5462\uff1f \u6bd4\u5982\u6211\u4eec\u60f3\u77e5\u9053\u4e00\u4e2a\u7535\u5f71\u7684\u540d\u5b57\uff0c\u4f46\u662f\u8bb0\u4e0d\u8d77\u6765\u5177\u4f53\u7684\u540d\u5b57\uff0c\u53ea\u77e5\u9053\u90e8\u5206\u5173\u952e\u8bcd\u6216\u8005\u5267\u60c5\u7684\u5185\u5bb9\uff0c\u90a3\u8fd9\u79cd\u60c5\u666f\u80cc\u540e\u5982\u4f55\u7528\u6280\u672f\u89e3\u51b3\u5462\uff1f\r\n\u8fd9\u65f6\u5019\u5c31\u4e0d\u5f97\u4e0d\u63d0\u5230\u5012\u6392\u7d22\u5f15\u4e86\r\n\u4ee5\u4e0b\u5c31\u662f\u4e00\u4e2a\u5012\u6392\u7d22\u5f15\u7684\u4f8b\u5b50\r<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"605\" height=\"755\" src=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-103.png\" alt=\"\" class=\"wp-image-1516\" srcset=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-103.png 605w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-103-240x300.png 240w\" sizes=\"(max-width: 605px) 100vw, 605px\" \/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>\u4f46\u662f\u8fd9\u6837\u6570\u636e\u91cf\u5c31\u592a\u5927\u4e86\uff0c\u8fd8\u53ef\u4ee5\u8fd9\u6837\u538b\u7f29<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"551\" height=\"379\" src=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-104.png\" alt=\"\" class=\"wp-image-1517\" srcset=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-104.png 551w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-104-300x206.png 300w\" sizes=\"(max-width: 551px) 100vw, 551px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc_0\">2.Elasticsearch\u5b89\u88c5<\/h2>\n\n\n\n<p><strong><em>1.\u5173\u95ed\u9632\u706b\u5899\u548cSelinux\u5e76\u4e0b\u8f7d\u8f6f\u4ef6\u5305<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl stop firewalld.service\r\nsetenforce 0\r\nmkdir \/data\/soft -p\r\ncd \/data\/soft\/\r\nwget https:\/\/artifacts.elastic.co\/downloads\/elasticsearch\/elasticsearch-7.9.1-x86_64.rpm\r<\/code><\/pre>\n\n\n\n<p><strong><em>2.\u5b89\u88c5jdk\u5e76\u5728\u5b89\u88c5ES\u540e\u542f\u52a8\u68c0\u67e5<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u5bf9\u4e8eElasticsearch7.0\u4e4b\u540e\u7684\u7248\u672c\u4e0d\u9700\u8981\u518d\u72ec\u7acb\u7684\u5b89\u88c5JDK\u4e86\uff0c\u8f6f\u4ef6\u5305\u91cc\u5df2\u7ecf\u81ea\u5e26\u4e86\u6700\u65b0\u7684JDK\uff0c\u6240\u4ee5\u76f4\u63a5\u542f\u52a8\u5373\u53ef\u3002\r\nyum localinstall -y elasticsearch-7.9.1-x86_64.rpm\r\nsystemctl daemon-reload\r\nsystemctl enable elasticsearch.service\r\nsystemctl start elasticsearch.service\r\nnetstat -lntup|grep 9200\r\ncurl 127.0.0.1:9200\r<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc_0\">3.Elasticsearch\u81ea\u5b9a\u4e49\u914d\u7f6e<\/h2>\n\n\n\n<p><strong><em>1.\u67e5\u770bES\u6709\u54ea\u4e9b\u914d\u7f6e\u6587\u4ef6<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@node01 ~]#  rpm -qc elasticsearch\r\n\/etc\/elasticsearch\/elasticsearch.yml #\u4e3b\u914d\u7f6e\u6587\u4ef6\r\n\/etc\/elasticsearch\/jvm.options #JVM\u914d\u7f6e\u6587\u4ef6\r\n\/etc\/init.d\/elasticsearch #init\u542f\u52a8\u811a\u672c\r\n\/etc\/sysconfig\/elasticsearch #\u73af\u5883\u53d8\u91cf\u6587\u4ef6\r\n\/usr\/lib\/sysctl.d\/elasticsearch.conf #\u5185\u6838\u53c2\u6570\u6587\u4ef6\r\n\/usr\/lib\/systemd\/system\/elasticsearch.service#systemd\u542f\u52a8\u6587\u4ef6\r<\/code><\/pre>\n\n\n\n<p><strong><em>2.\u7f16\u8f91\u914d\u7f6e\u6587\u4ef6<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@node01 ~]# grep -E \"^&#91;a-Z]\" \/etc\/elasticsearch\/elasticsearch.yml \r\nnode.name: es-01#####\u8282\u70b9\u540d\u79f0\r\npath.data: \/var\/lib\/elasticsearch####\u6570\u636e\u76ee\u5f55\r\npath.logs: \/var\/log\/elasticsearch####\u65e5\u5fd7\u76ee\u5f55\r\nbootstrap.memory_lock: true####\u9501\u5185\u5b58\uff0c\u4e0d\u4f7f\u7528swap\u5206\u533a\r\nnetwork.host: 0.0.0.0###\u76d1\u542c\u7684\u7f51\u7edc\u5730\u5740\r\nhttp.port: 9200####\u76d1\u542c\u7684\u7aef\u53e3\r\ndiscovery.seed_hosts: &#91;\"10.0.0.80\"]####\u81ea\u52a8\u53d1\u73b0\u7684\u4e3b\u673a\r\ncluster.initial_master_nodes: &#91;\"10.0.0.80\"]####\u53c2\u4e0emaster\u9009\u4e3e\u7684\u8282\u70b9\r<\/code><\/pre>\n\n\n\n<p><strong><em>3.\u91cd\u542f\u670d\u52a1\u5e76\u89e3\u51b3\u5185\u5b58\u9501\u5b9a\u5931\u8d25\u95ee\u9898<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl restart elasticsearch.service\n\u91cd\u542f\u53d1\u73b0\u63d0\u793a\u5185\u5b58\u9501\u5b9a\u5931\u8d25\uff0c\u9700\u8981\u6839\u636e\u5b98\u7f51\u5e2e\u52a9\u624b\u518c\u4fee\u6539\u542f\u52a8\u6587\u4ef6\r\nhttps:&#47;&#47;www.elastic.co\/guide\/en\/elasticsearch\/reference\/current\/setting-system-settings.html#systemd\r\nsystemctl edit elasticsearch\r\n&#91;Service]\r\nLimitMEMLOCK=infinity\r\nsystemctl daemon-reload\r\nsystemctl restart elasticsearch.service\r<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc_0\">4.Elasticsearch\u63d2\u4ef6\u5b89\u88c5<\/h2>\n\n\n\n<p><strong><em>1.elasticsearch-head\u4ecb\u7ecd<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u5b98\u65b9\u5730\u5740\uff1a https:\/\/github.com\/mobz\/elasticsearch-head\r\nelasticsearch-head\u662f\u4e00\u6b3e\u7528\u6765\u7ba1\u7406Elasticsearch\u96c6\u7fa4\u7684\u7b2c\u4e09\u65b9\u63d2\u4ef6\u5de5\u5177\u3002\r\nelasticsearch-Head\u63d2\u4ef6\u57285.0\u7248\u672c\u4e4b\u524d\u53ef\u4ee5\u76f4\u63a5\u4ee5\u63d2\u4ef6\u7684\u5f62\u5f0f\u76f4\u63a5\u5b89\u88c5\uff0c\u4f46\u662f5.0\u4ee5\u540e\u5b89\u88c5\u65b9\u5f0f\u53d1\u751f\u4e86\u6539\u53d8\uff0c\u9700\u8981nodejs\u73af\u5883\u652f\u6301\uff0c\u6216\u8005\u76f4\u63a5 \u4f7f\u7528\u522b\u4eba\u5c01\u88c5\u597d\u7684docker\u955c\u50cf\uff0c\u66f4\u63a8\u8350\u7684\u662f\u8c37\u6b4c\u6d4f\u89c8\u5668\u7684\u63d2\u4ef6\r<\/code><\/pre>\n\n\n\n<p><strong><em>2.elasticsearch-head\u7684\u4e09\u79cd\u5b89\u88c5\u65b9\u5f0f<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>1.docker\u5b89\u88c5elasticsearch-head<\/strong>\r\ndocker run -p 9100:9100 mobz\/elasticsearch-head:7\r\n<strong>2.npm\u5b89\u88c5elasticsearch-head<\/strong>\r\ncd \/opt\/\r\nwget https:\/\/nodejs.org\/dist\/v12.13.0\/node-v12.13.0-linux-x64.tar.xz\r\ntar xf node-v12.13.0-linux-x64.tar.xz\r\nmv node-v12.13.0-linux-x64 node\r\necho 'export PATH=$PATH:\/opt\/node\/bin' >> \/etc\/profile\r\nsource \/etc\/profile\r\nnpm -v\r\nnode -v\r\ngit clone git:\/\/github.com\/mobz\/elasticsearch-head.git\r\ncd elasticsearch-head\r\nnpm install -g cnpm --registry=https:\/\/registry.npm.taobao.org\r\ncnpm install\r\ncnpm run start\r\n\u4fee\u6539Elasticsearch\u914d\u7f6e\u6587\u4ef6\uff0c\u6dfb\u52a0\u5982\u4e0b\u53c2\u6570\u5e76\u91cd\u542f\r\nhttp.cors.enabled: true\r\nhttp.cors.allow-origin: \"*\"\r\n<strong>3.es-head\u8c37\u6b4c\u6d4f\u89c8\u5668\u63d2\u4ef6\u5b89\u88c5<\/strong>\r\n\u66f4\u591a\u5de5\u5177-->\u62d3\u5c55\u7a0b\u5e8f-->\u5f00\u53d1\u8005\u6a21\u5f0f-->\u9009\u62e9\u89e3\u538b\u7f29\u540e\u7684\u63d2\u4ef6\u76ee\u5f55\r\n\u6d4b\u8bd5\u8fde\u63a5elasticsearch\r<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"865\" height=\"195\" src=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-105.png\" alt=\"\" class=\"wp-image-1526\" srcset=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-105.png 865w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-105-300x68.png 300w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-105-768x173.png 768w\" sizes=\"(max-width: 865px) 100vw, 865px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc_0\">5.\u5b89\u88c5kibana\u8fde\u63a5es\u6570\u636e\u5e93<\/h2>\n\n\n\n<p><strong><em>1.\u5b89\u88c5kibana\u4fee\u6539\u914d\u7f6e\u6587\u4ef6<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>##\u5b89\u88c5\nwget https:\/\/artifacts.elastic.co\/downloads\/kibana\/kibana-7.14.0-x86_64.rpm\r\nyum localinstall -y kibana-7.14.0-x86_64.rpm\r\n##\u914d\u7f6e\u6587\u4ef6\n&#91;root@node01 ~]# grep -E \"^&#91;a-Z]\" \/etc\/kibana\/kibana.yml \r\nserver.port: 5601###\u670d\u52a1\u7aef\u53e3\r\nserver.host: \"0.0.0.0\"###\u76d1\u542c\u7684\u5730\u5740\r\nelasticsearch.hosts: &#91;\"http:\/\/10.0.0.80:9200\"]###es\u5730\u5740\r\nkibana.index: \".kibana\"##\u7d22\u5f15\u540d\r\ni18n.locale: \"zh-CN\"###\u4e2d\u6587\u6c49\u5316\r<\/code><\/pre>\n\n\n\n<p><strong><em>2.\u542f\u52a8kibana\u5e76\u767b\u5f55\u68c0\u67e5\u6d4b\u8bd5<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl start kibana\nhttp:&#47;&#47;10.0.0.51:5601\/<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"865\" height=\"410\" src=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-106.png\" alt=\"\" class=\"wp-image-1529\" srcset=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-106.png 865w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-106-300x142.png 300w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-106-768x364.png 768w\" sizes=\"(max-width: 865px) 100vw, 865px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc_0\">6.Elasticsearch\u63d2\u5165\u547d\u4ee4<\/h2>\n\n\n\n<p><strong><em>1.Elasticsearch\u6570\u636e\u683c\u5f0f<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u548cMySQL\u5bf9\u6bd4:\r\nMySQL             Elasticsearch\r\n\u5e93                 \u7d22\u5f15 index\r\n\u8868                 \u7c7b\u578b _doc\r\n\u5b57\u6bb5               json\u6570\u636e\u7684key\r\n\u503c                 json\u6570\u636e\u7684value\r\n\u884c                 \u6587\u6863 doc\r<\/code><\/pre>\n\n\n\n<p><strong><em>2.\u4f7f\u7528\u81ea\u5b9a\u4e49\u7684ID<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>curl\u547d\u4ee4\u64cd\u4f5c<\/strong>\r\n&#91;root@node01 ~]# curl -XPUT 'http:\/\/10.0.0.80:9200\/linux\/_doc\/1' -H 'Content-Type: application\/json' -d '\r\n{\r\n \"name\": \"zhang\",\r\n \"age\": \"29\"\r\n}'\r\n<strong>kibana\u754c\u9762\u64cd\u4f5c\uff1a <\/strong>\nPUT linux\/_doc\/1\r\n{\r\n\"name\": \"zhang\",\r\n\"age\": \"29\"\r\n}\r\n<strong>###\u6ce8\u610f\uff0c\u5982\u679cweb\u9875\u9762\u76f4\u63a5\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\uff0c\u5c06\u521b\u5efa\u968f\u673aid<\/strong>\r\nPUT linux\/_doc\/\r\n{\r\n\"name\": \"zhang\",\r\n\"age\": \"29\"\r\n}\r<\/code><\/pre>\n\n\n\n<p><strong><em>3.\u548cmysql\u6570\u636e\u5bf9\u5e94\u5173\u7cfb<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql\r\nid name   age address job\r\n1 zhang   27  BJ     it\r\n2 ya      22  SZ     it\r\n\r\n\r\nPOST linux\/_doc\/\r\n{\r\n \"id\": \"1\",\r\n \"name\": \"zhang\",\r\n \"age\": \"29\",\r\n \"address\": \"BJ\",\r\n \"job\": \"it\"\r\n}\r\nPOST linux\/_doc\/\r\n{\r\n \"id\": \"2\",\r\n \"name\": \"ya\",\r\n \"age\": \"22\",\r\n \"address\": \"SZ\",\r\n \"job\": \"it\"\r\n}\r<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc_0\">7.kibana\u9875\u9762\u7684Elasticsearch\u67e5\u8be2\u547d\u4ee4<\/h2>\n\n\n\n<p><strong><em>1.\u521b\u5efa\u6d4b\u8bd5\u8bed\u53e5<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>POST linux\/_doc\/1\r\n{\r\n  \"name\":\"www\",\r\n  \"age\":\"14\"\r\n}\r<\/code><\/pre>\n\n\n\n<p><strong><em>2.\u7b80\u5355\u67e5\u8be2<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>GET linux\/_search\/<\/code><\/pre>\n\n\n\n<p><strong><em>3.\u6761\u4ef6\u67e5\u8be2<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#term\u67e5\u8be2 \u4e00\u822c\u6839\u636e \u6570\u636e\u6587\u6863\u4e2d \u67d0\u4e00\u4e2a\u952e\u503c\u7684\u5185\u5bb9\u8fdb\u884c\u67e5\u8be2\r\nGET sunfuyang\/_search\r\n{\r\n \"query\": {\r\n   \"term\": {\r\n     \"name\": {\r\n       \"value\": \"wang\"\r\n     }\r\n   }\r\n }\r\n}\r<\/code><\/pre>\n\n\n\n<p><strong><em>4.\u591a\u6761\u4ef6\u67e5\u8be2<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>GET linux\/_search\r\n{\r\n \"query\": {\r\n   \"bool\": {\r\n     \"must\": &#91;\r\n       {\r\n         \"term\": {\r\n           \"address.keyword\": \"BJ\"\r\n         }\r\n       },\r\n       {\r\n         \"term\": {\r\n           \"job.keyword\": \"dev\"\r\n         }\r\n       },\r\n       {\r\n         \"range\": {\r\n           \"age.keyword\": {\r\n             \"gt\": \"24\",\r\n             \"lt\": \"31\"\r\n           }\r\n         }\r\n       }\r\n     ]\r\n   }\r\n }\r\n}\r<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc_0\">8.kibana\u9875\u9762\u7684Elasticsearch\u66f4\u65b0\u547d\u4ee4<\/h2>\n\n\n\n<p><strong><em>1.\u81ea\u5b9a\u4e49ID\u7684\u5185\u5bb9\u66f4\u65b0<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>PUT linux\/_doc\/1\r\n{\r\n  \"name\":\"www\",\r\n  \"age\":\"14\"\r\n}\r<\/code><\/pre>\n\n\n\n<p><strong><em>2.\u968f\u673aID\u66f4\u65b0<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>\u521b\u5efa\u6d4b\u8bd5\u6570\u636e<\/strong>\r\nPUT linux\/_doc\/1\r\n{\r\n \"name\": \"zhang\",\r\n \"age\": \"30\",\r\n \"job\": \"it\",\r\n \"id\": 2\r\n}\r\n<strong>\u5148\u6839\u636e\u81ea\u5b9a\u4e49\u7684Id\u5b57\u6bb5\u67e5\u51fa\u6570\u636e\u7684\u968f\u673aID<\/strong>\r\nGET linux\/_search\/\r\n{\r\n \"query\": {\r\n   \"term\": {\r\n     \"id\": {\r\n       \"value\": \"2\"\r\n     }\r\n   }\r\n }\r\n}\r\n\u53d6\u5230\u968f\u673aID\u540e\u4f7f\u7528put\u66f4\u6539\u6570\u636e\r<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc_0\">9.kibana\u9875\u9762\u7684Elasticsearch\u5220\u9664\u547d\u4ee4<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>DELETE linux\/_doc\/1<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b59\u5bcc\u9633\uff0c \u6c5f\u6e56\u4eba\u79f0\u6ca1\u4eba\u79f0\u3002\u591a\u5e74\u4e92\u8054\u7f51\u8fd0\u7ef4\u5de5\u4f5c\u7ecf\u9a8c\uff0c\u66fe\u8d1f\u8d23\u8fc7\u5b59\u5e03\u65af\u5927\u89c4\u6a21\u96c6\u7fa4\u67b6\u6784\u81ea\u52a8\u5316\u8fd0\u7ef4\u7ba1\u7406\u5de5\u4f5c\u3002\u64c5\u957fWeb\u96c6 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":246,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[],"_links":{"self":[{"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/posts\/1511"}],"collection":[{"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1511"}],"version-history":[{"count":14,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/posts\/1511\/revisions"}],"predecessor-version":[{"id":1540,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/posts\/1511\/revisions\/1540"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/media\/246"}],"wp:attachment":[{"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1511"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1511"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1511"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}