{"id":40577,"date":"2022-12-26T16:32:25","date_gmt":"2024-02-04T14:31:24","guid":{"rendered":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8-macos-%e4%b8%8a%e6%9e%84%e5%bb%ba-elasticsearch-7-%e5%b9%b6%e8%bf%9b%e8%a1%8c%e5%85%a8%e6%96%87%e6%90%9c%e7%b4%a2%e3%80%82\/"},"modified":"2024-04-29T07:04:08","modified_gmt":"2024-04-28T23:04:08","slug":"%e5%9c%a8-macos-%e4%b8%8a%e6%9e%84%e5%bb%ba-elasticsearch-7-%e5%b9%b6%e8%bf%9b%e8%a1%8c%e5%85%a8%e6%96%87%e6%90%9c%e7%b4%a2%e3%80%82","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8-macos-%e4%b8%8a%e6%9e%84%e5%bb%ba-elasticsearch-7-%e5%b9%b6%e8%bf%9b%e8%a1%8c%e5%85%a8%e6%96%87%e6%90%9c%e7%b4%a2%e3%80%82\/","title":{"rendered":"\u5728 macOS \u4e0a\u6784\u5efa Elasticsearch 7 \u5e76\u8fdb\u884c\u5168\u6587\u641c\u7d22"},"content":{"rendered":"<h2>\u603b\u7ed3<\/h2>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">Homebrew \u3067 Elasticsearch 7 \u3092 macOS \u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">Elasticsearch \u306b\u30c7\u30fc\u30bf\u3092\u5165\u308c\u3066\u5168\u6587\u691c\u7d22\u3059\u308b<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\u4eca\u56de\u306e\u74b0\u5883: macOS Catalina + Elasticsearch 7.8<\/ul>\n<h2>\u5b89\u88dd<\/h2>\n<p>\u6309\u7167\u201cInstall Elasticsearch on macOS with Homebrew | Elasticsearch Reference [7.8] | Elastic\u201d\u4e0a\u6240\u8ff0\u7684\u6b65\u9aa4\uff0c\u5728macOS\u4e0a\u4f7f\u7528Homebrew\u5b89\u88c5Elasticsearch\u3002<\/p>\n<pre class=\"post-pre\"><code>$ brew tap elastic\/tap\r\n$ brew install elastic\/tap\/elasticsearch-full\r\n<\/code><\/pre>\n<h2>\u51c6\u5907\u914d\u7f6e\u6587\u4ef6<\/h2>\n<p>\u9019\u6b21\u6211\u5011\u5c07\u8a2d\u7f6e\u6a94\u6848\u7684\u76ee\u9304\u6e96\u5099\u5728\u4efb\u610f\u4f4d\u7f6e\u3002<\/p>\n<pre class=\"post-pre\"><code>$ mkdir elasticsearch\r\n$ cd elasticsearch\r\n<\/code><\/pre>\n<p>\u4ece\u9ed8\u8ba4\u8bbe\u7f6e\u6587\u4ef6\u4e2d\u590d\u5236\u6700\u57fa\u672c\u6240\u9700\u7684\u5185\u5bb9\u3002<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">elasticsearch.yml: Elasticsearch \u306e\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">jvm.options: JVM \u306e\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">log4j2.properties: \u30ed\u30b0\u51fa\u529b\u306e\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb<\/ul>\n<pre class=\"post-pre\"><code>$ cp \/usr\/local\/etc\/elasticsearch\/elasticsearch.yml .\r\n$ cp \/usr\/local\/etc\/elasticsearch\/jvm.options .\r\n$ cp \/usr\/local\/etc\/elasticsearch\/log4j2.properties .\r\n<\/code><\/pre>\n<p>\u5c06elasticsearch.yml\u6587\u4ef6\u7684\u5185\u5bb9\u4fee\u6539\u5982\u4e0b\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"na\">cluster<\/span><span class=\"pi\">:<\/span>\r\n  <span class=\"na\">name<\/span><span class=\"pi\">:<\/span> <span class=\"s\">mycluster<\/span>\r\n<span class=\"na\">node<\/span><span class=\"pi\">:<\/span>\r\n  <span class=\"na\">name<\/span><span class=\"pi\">:<\/span> <span class=\"s\">mynode<\/span>\r\n<span class=\"na\">network<\/span><span class=\"pi\">:<\/span>\r\n  <span class=\"na\">host<\/span><span class=\"pi\">:<\/span> <span class=\"s\">localhost<\/span>\r\n<span class=\"na\">path<\/span><span class=\"pi\">:<\/span>\r\n  <span class=\"na\">data<\/span><span class=\"pi\">:<\/span> <span class=\"s\">\/usr\/local\/var\/lib\/elasticsearch\/<\/span>\r\n  <span class=\"na\">logs<\/span><span class=\"pi\">:<\/span> <span class=\"s\">\/usr\/local\/var\/log\/elasticsearch\/<\/span>\r\n<\/code><\/pre>\n<h2>\u542f\u52a8 Elasticsearch<\/h2>\n<p>\u5c06\u5b58\u653e\u8bbe\u7f6e\u6587\u4ef6\u7684\u76ee\u5f55\u6307\u5b9a\u4e3a\u73af\u5883\u53d8\u91cf ES_PATH_CONF\u3002<\/p>\n<pre class=\"post-pre\"><code>$ export ES_PATH_CONF=\/Users\/foo\/elasticsearch\r\n<\/code><\/pre>\n<p>\u4f7f\u7528 Elasticsearch \u547d\u4ee4\u542f\u52a8\u3002<\/p>\n<pre class=\"post-pre\"><code>$ elasticsearch\r\n<\/code><\/pre>\n<p>\u4ece\u53e6\u4e00\u4e2a\u7ec8\u7aef\u4f7f\u7528curl\u6765\u8bbf\u95eeElasticsearch\u5e76\u786e\u8ba4\u5176\u5df2\u542f\u52a8\u3002<\/p>\n<pre class=\"post-pre\"><code>$ curl http:\/\/localhost:9200\/\r\n{\r\n  \"name\" : \"mynode\",\r\n  \"cluster_name\" : \"mycluster\",\r\n  \"cluster_uuid\" : \"XXXXXXXXXXXXXXXXXXXXXX\",\r\n  \"version\" : {\r\n    \"number\" : \"7.8.0\",\r\n    \"build_flavor\" : \"default\",\r\n    \"build_type\" : \"tar\",\r\n    \"build_hash\" : \"757314695644ea9a1dc2fecd26d1a43856725e65\",\r\n    \"build_date\" : \"2020-06-14T19:35:50.234439Z\",\r\n    \"build_snapshot\" : false,\r\n    \"lucene_version\" : \"8.5.1\",\r\n    \"minimum_wire_compatibility_version\" : \"6.8.0\",\r\n    \"minimum_index_compatibility_version\" : \"6.0.0-beta1\"\r\n  },\r\n  \"tagline\" : \"You Know, for Search\"\r\n}\r\n<\/code><\/pre>\n<h2>Elasticsearch \u7684 REST API<\/h2>\n<p>Elasticsearch \u63d0\u4f9b\u4e86\u7528\u4e8e\u7ba1\u7406\u548c\u64cd\u4f5c\u7684 REST API\u3002<br \/>\n\u672c\u6b21\u4f7f\u7528 curl \u8c03\u7528 REST API \u6765\u8fdb\u884c\u6570\u636e\u6dfb\u52a0\u548c\u641c\u7d22\u3002<\/p>\n<p>REST APIs | Elasticsearch \u53c2\u8003\u6587\u6863 [7.8] | Elastic<\/p>\n<h2>\u521b\u5efa\u7d22\u5f15<\/h2>\n<p>\u521b\u5efa\u4e00\u4e2a\u4f5c\u4e3a\u5b58\u653e\u6570\u636e\u7684\u5bb9\u5668\u7684\u7d22\u5f15\u3002<br \/>\n\u7d22\u5f15\u7c7b\u4f3c\u4e8e\u5173\u7cfb\u578b\u6570\u636e\u5e93\u4e2d\u7684\u8868\u3002<\/p>\n<p>\u53ef\u4ee5\u4f7f\u7528HTTP PUT\u65b9\u6cd5\u521b\u5efa\u7d22\u5f15\u3002<\/p>\n<p>\u521b\u5efa\u7d22\u5f15API | Elasticsearch\u53c2\u8003[7.8] | Elastic<\/p>\n<pre class=\"post-pre\"><code>PUT \/&lt;index&gt;\r\n<\/code><\/pre>\n<p>\u901a\u8fc7\u6dfb\u52a0 pretty \u53c2\u6570\uff0c\u53ef\u4ee5\u4f7f\u54cd\u5e94\u7684 JSON \u683c\u5f0f\u66f4\u6613\u8bfb\uff0c\u540c\u65f6\u5728\u6b64\u5904\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a foo_index \u7684\u7d22\u5f15\u3002<\/p>\n<pre class=\"post-pre\"><code>$ curl --include -XPUT \"http:\/\/localhost:9200\/foo_index?pretty\"\r\nHTTP\/1.1 200 OK\r\ncontent-type: application\/json; charset=UTF-8\r\ncontent-length: 85\r\n\r\n{\r\n  \"acknowledged\" : true,\r\n  \"shards_acknowledged\" : true,\r\n  \"index\" : \"foo_index\"\r\n}\r\n<\/code><\/pre>\n<p>\u53ef\u4ee5\u901a\u8fc7HTTP GET\u8bf7\u6c42\u6765\u786e\u8ba4\u5df2\u521b\u5efa\u7684\u7d22\u5f15\u3002<\/p>\n<p>\u83b7\u53d6\u7d22\u5f15 API | Elasticsearch \u53c2\u8003\u6587\u6863 [7.8] | Elastic<\/p>\n<pre class=\"post-pre\"><code>GET \/&lt;index&gt;\r\n<\/code><\/pre>\n<p>\u83b7\u53d6foo_index\u7684\u7d22\u5f15\u4fe1\u606f\u3002<\/p>\n<pre class=\"post-pre\"><code>$ curl --include -XGET \"http:\/\/localhost:9200\/foo_index?pretty\"\r\nHTTP\/1.1 200 OK\r\ncontent-type: application\/json; charset=UTF-8\r\ncontent-length: 379\r\n\r\n{\r\n  \"foo_index\" : {\r\n    \"aliases\" : { },\r\n    \"mappings\" : { },\r\n    \"settings\" : {\r\n      \"index\" : {\r\n        \"creation_date\" : \"1595771960816\",\r\n        \"number_of_shards\" : \"1\",\r\n        \"number_of_replicas\" : \"1\",\r\n        \"uuid\" : \"D7t0dUBPSqKKyvw5Z7eujw\",\r\n        \"version\" : {\r\n          \"created\" : \"7080099\"\r\n        },\r\n        \"provided_name\" : \"foo_index\"\r\n      }\r\n    }\r\n  }\r\n}\r\n<\/code><\/pre>\n<h2>\u6dfb\u52a0\u6587\u4ef6<\/h2>\n<p>\u6587\u6863\u5728\u5173\u7cfb\u578b\u6570\u636e\u5e93\u4e2d\u7c7b\u4f3c\u4e8e\u8bb0\u5f55\u7684\u6982\u5ff5\u3002<br \/>\n\u6587\u6863\u4f7f\u7528JSON\u683c\u5f0f\u8868\u793a\u3002<\/p>\n<p>\u53ef\u4ee5\u4f7f\u7528HTTP POST\u65b9\u6cd5\u6dfb\u52a0\u6587\u6863\u3002<\/p>\n<p>\u7d22\u5f15 API | Elasticsearch \u53c2\u8003[7.8] | Elastic<\/p>\n<pre class=\"post-pre\"><code>POST \/&lt;index&gt;\/_doc\/\r\n<\/code><\/pre>\n<p>\u5728\u8fd9\u91cc\u6ce8\u518c\u4e00\u4e2a\u5177\u6709foo_user\u548cfoo_message\u5b57\u6bb5\u7684\u6587\u6863\u3002<br \/>\n\u6587\u6863\u7684ID\u5c06\u4f1a\u81ea\u52a8\u751f\u6210\uff08\u4e5f\u53ef\u4ee5\u6307\u5b9aID\uff09\u3002\u8fd9\u6b21\u751f\u6210\u4e86\u4e00\u4e2aID\u4e3a\u201c9xNyi3MBhHaU2qi75ayU\u201d\u7684\u6587\u6863\u3002<\/p>\n<pre class=\"post-pre\"><code>$ curl --include -XPOST \"http:\/\/localhost:9200\/foo_index\/_doc?pretty\" \\\r\n-H 'Content-Type: application\/json' \\\r\n-d '{\r\n  \"foo_user\": \"Alice\",\r\n  \"foo_message\": \"The night was young, and so was he. But the night was sweet, and he was sour.\"\r\n}'\r\nHTTP\/1.1 201 Created\r\nLocation: \/foo_index\/_doc\/9xNyi3MBhHaU2qi75ayU\r\ncontent-type: application\/json; charset=UTF-8\r\ncontent-length: 242\r\n\r\n{\r\n  \"_index\" : \"foo_index\",\r\n  \"_type\" : \"_doc\",\r\n  \"_id\" : \"9xNyi3MBhHaU2qi75ayU\",\r\n  \"_version\" : 1,\r\n  \"result\" : \"created\",\r\n  \"_shards\" : {\r\n    \"total\" : 2,\r\n    \"successful\" : 1,\r\n    \"failed\" : 0\r\n  },\r\n  \"_seq_no\" : 2,\r\n  \"_primary_term\" : 1\r\n}\r\n<\/code><\/pre>\n<p>\u53ef\u4ee5\u4f7f\u7528HTTP GET\u65b9\u6cd5\u6765\u67e5\u770b\u6dfb\u52a0\u7684\u6587\u6863\u3002<\/p>\n<p>\u83b7\u53d6API | Elasticsearch \u53c2\u8003\u6587\u6863 [7.8] | Elastic<\/p>\n<pre class=\"post-pre\"><code>GET &lt;index&gt;\/_doc\/&lt;_id&gt;\r\n<\/code><\/pre>\n<p>\u4f7f\u7528\u6307\u5b9a\u7684\u6807\u8bc6\u7b26\u6765\u83b7\u53d6\u6587\u6863\u7684\u4fe1\u606f\u3002<\/p>\n<pre class=\"post-pre\"><code>$ curl --include -XGET \"http:\/\/localhost:9200\/foo_index\/_doc\/9xNyi3MBhHaU2qi75ayU?pretty\"\r\nHTTP\/1.1 200 OK\r\ncontent-type: application\/json; charset=UTF-8\r\ncontent-length: 306\r\n\r\n{\r\n  \"_index\" : \"foo_index\",\r\n  \"_type\" : \"_doc\",\r\n  \"_id\" : \"9xNyi3MBhHaU2qi75ayU\",\r\n  \"_version\" : 1,\r\n  \"_seq_no\" : 2,\r\n  \"_primary_term\" : 1,\r\n  \"found\" : true,\r\n  \"_source\" : {\r\n    \"foo_user\" : \"Alice\",\r\n    \"foo_message\" : \"The night was young, and so was he. But the night was sweet, and he was sour.\"\r\n  }\r\n}\r\n<\/code><\/pre>\n<p>\u8bf7\u5c06\u7b2c\u4e8c\u4e2a\u6587\u4ef6\u4e5f\u6dfb\u52a0\u8fdb\u53bb\u3002<\/p>\n<pre class=\"post-pre\"><code>$ curl --include -XPOST \"http:\/\/localhost:9200\/foo_index\/_doc?pretty\" \\\r\n-H 'Content-Type: application\/json' \\\r\n-d '{\r\n  \"foo_user\": \"\u30dc\u30d6\",\r\n  \"foo_message\": \"\u591c\u306f\u82e5\u304f\u3001\u5f7c\u3082\u82e5\u304b\u3063\u305f\u3002\u304c\u3001\u591c\u306e\u7a7a\u6c17\u306f\u7518\u3044\u306e\u306b\u3001\u5f7c\u306e\u6c17\u5206\u306f\u82e6\u304b\u3063\u305f\u3002\"\r\n}'\r\nHTTP\/1.1 201 Created\r\nLocation: \/foo_index\/_doc\/-BNzi3MBhHaU2qi7EazP\r\ncontent-type: application\/json; charset=UTF-8\r\ncontent-length: 242\r\n\r\n{\r\n  \"_index\" : \"foo_index\",\r\n  \"_type\" : \"_doc\",\r\n  \"_id\" : \"-BNzi3MBhHaU2qi7EazP\",\r\n  \"_version\" : 1,\r\n  \"result\" : \"created\",\r\n  \"_shards\" : {\r\n    \"total\" : 2,\r\n    \"successful\" : 1,\r\n    \"failed\" : 0\r\n  },\r\n  \"_seq_no\" : 3,\r\n  \"_primary_term\" : 1\r\n}\r\n<\/code><\/pre>\n<h2>\u6570\u636e\u7684\u5168\u6587\u641c\u7d22<\/h2>\n<p>\u4f60\u53ef\u4ee5\u4f7f\u7528Elasticsearch\u7684\u67e5\u8be2DSL\u6765\u641c\u7d22\u6587\u6863\u3002<\/p>\n<p>\u67e5\u8be2DSL | Elasticsearch \u53c2\u8003\u624b\u518c [7.8] | Elastic<\/p>\n<p>\u5728\u67e5\u8be2 DSL \u4e2d\uff0c\u4f7f\u7528 JSON \u683c\u5f0f\u6765\u6307\u5b9a\u641c\u7d22\u6761\u4ef6\u3002<\/p>\n<p>\u67e5\u8be2\u5339\u914d | Elasticsearch\u53c2\u8003 [7.8] | Elastic<\/p>\n<pre class=\"post-pre\"><code>GET \/_search\r\n{\r\n  \"query\": {\r\n    \"match\": {\r\n      \"message\": {\r\n        \"query\": \"this is a test\"\r\n      }\r\n    }\r\n  }\r\n}\r\n<\/code><\/pre>\n<p>\u5728\u8fd9\u91cc\u6267\u884c\u4e00\u4e2a\u67e5\u8be2\uff0c\u6765\u641c\u7d22\u5305\u542b&#8221;\u591c\u7684\u7a7a\u6c14&#8221;\u7684\u6587\u6863\uff0c\u5176\u4e2d\u5305\u62ec foo_message \u5b57\u6bb5\u3002<\/p>\n<pre class=\"post-pre\"><code>$ curl --include -XGET \"http:\/\/localhost:9200\/foo_index\/_search?pretty\" \\\r\n-H 'Content-Type: application\/json' \\\r\n-d '\r\n{\r\n  \"query\": {\r\n    \"match\": {\r\n      \"foo_message\": \"\u591c\u306e\u7a7a\u6c17\"\r\n    }\r\n  }\r\n}'\r\nHTTP\/1.1 200 OK\r\ncontent-type: application\/json; charset=UTF-8\r\ncontent-length: 611\r\n\r\n{\r\n  \"took\" : 16,\r\n  \"timed_out\" : false,\r\n  \"_shards\" : {\r\n    \"total\" : 1,\r\n    \"successful\" : 1,\r\n    \"skipped\" : 0,\r\n    \"failed\" : 0\r\n  },\r\n  \"hits\" : {\r\n    \"total\" : {\r\n      \"value\" : 1,\r\n      \"relation\" : \"eq\"\r\n    },\r\n    \"max_score\" : 3.4337347,\r\n    \"hits\" : [\r\n      {\r\n        \"_index\" : \"foo_index\",\r\n        \"_type\" : \"_doc\",\r\n        \"_id\" : \"-BNzi3MBhHaU2qi7EazP\",\r\n        \"_score\" : 3.4337347,\r\n        \"_source\" : {\r\n          \"foo_user\" : \"\u30dc\u30d6\",\r\n          \"foo_message\" : \"\u591c\u306f\u82e5\u304f\u3001\u5f7c\u3082\u82e5\u304b\u3063\u305f\u3002\u304c\u3001\u591c\u306e\u7a7a\u6c17\u306f\u7518\u3044\u306e\u306b\u3001\u5f7c\u306e\u6c17\u5206\u306f\u82e6\u304b\u3063\u305f\u3002\"\r\n        }\r\n      }\r\n    ]\r\n  }\r\n}\r\n<\/code><\/pre>\n<h2>\u4f7f\u7528 REST API \u8fdb\u884c\u7d22\u5f15\u64cd\u4f5c\u7684\u793a\u4f8b\u3002<\/h2>\n<p>\u7d22\u5f15API | Elasticsearch\u53c2\u8003[7.8] | Elastic<\/p>\n<p>\u7ed9\u51fa\u4f7f\u7528 REST API \u5728\u547d\u4ee4\u884c\u5de5\u5177 curl \u4e2d\u64cd\u4f5c\u7d22\u5f15\u7684\u793a\u4f8b\u3002<\/p>\n<h3>\u521b\u5efa\u7d22\u5f15<\/h3>\n<p>\u521b\u5efa\u7d22\u5f15API | Elasticsearch\u53c2\u8003[7.8] | \u5f39\u6027\u641c\u7d22<\/p>\n<pre class=\"post-pre\"><code>$ curl -XPUT http:\/\/localhost:9200\/foo_index\r\n<\/code><\/pre>\n<h3>\u5220\u9664\u7d22\u5f15<\/h3>\n<p>\u5728Elasticsearch\u53c2\u8003\u6587\u6863[7.8]\u4e2d\uff0c\u5220\u9664\u7d22\u5f15\u7684API\u529f\u80fd\u3002<\/p>\n<pre class=\"post-pre\"><code>$ curl -XDELETE http:\/\/localhost:9200\/foo_index\r\n<\/code><\/pre>\n<h3>\u83b7\u53d6\u7d22\u5f15\u5217\u8868<\/h3>\n<p>\u732b API | Elasticsearch \u53c2\u8003\u624b\u518c [7.8] | Elastic<\/p>\n<pre class=\"post-pre\"><code>$ curl -XGET \"http:\/\/localhost:9200\/_cat\/indices?format=json\"\r\n<\/code><\/pre>\n<h2>\u4f7f\u7528REST API\u64cd\u4f5c\u6587\u6863\u7684\u793a\u4f8b\u3002<\/h2>\n<p>\u6587\u6863 APIs | Elasticsearch \u53c2\u8003 [7.8] | Elastic<\/p>\n<p>\u63d0\u4f9b\u4e00\u4e2a\u4f7f\u7528 REST API \u548c curl \u64cd\u4f5c\u6587\u6863\u7684\u793a\u4f8b\u3002<\/p>\n<h3>\u6dfb\u52a0\u6587\u4ef6<\/h3>\n<p>\u7d22\u5f15 API | Elasticsearch \u53c2\u8003\u6587\u6863 [7.8] | \u5f39\u6027\u641c\u7d22<\/p>\n<pre class=\"post-pre\"><code>$ curl -XPOST http:\/\/localhost:9200\/foo_index\/_doc \\\r\n-H 'Content-Type: application\/json' \\\r\n-d '{\"foo_user\": \"Carol\", \"foo_message\": \"Hello, world.\"}'\r\n<\/code><\/pre>\n<h3>\u83b7\u53d6\u6587\u6863<\/h3>\n<p>\u83b7\u53d6API | Elasticsearch \u53c2\u8003\u6587\u6863 [7.8] | Elastic<\/p>\n<pre class=\"post-pre\"><code>$ curl -XGET http:\/\/localhost:9200\/foo_index\/_doc\/XXXXXXXXXXXXXXXXXXXX\r\n<\/code><\/pre>\n<h3>\u66f4\u65b0\u6587\u4ef6<\/h3>\n<p>\u66f4\u65b0API | Elasticsearch\u53c2\u8003 [7.8] | \u5f39\u6027\u641c\u7d22<\/p>\n<pre class=\"post-pre\"><code>$ curl -XPUT http:\/\/localhost:9200\/foo_index\/_doc\/XXXXXXXXXXXXXXXXXXXX \\\r\n-H 'Content-Type: application\/json' \\\r\n-d '{\"foo_user\": \"Carol\", \"foo_message\": \"Goodbye, world.\"}'\r\n<\/code><\/pre>\n<h3>\u5220\u9664\u6587\u6863<\/h3>\n<p>\u5220\u9664API | Elasticsearch \u53c2\u8003 [7.8] | Elastic<\/p>\n<pre class=\"post-pre\"><code>$ curl -XDELETE http:\/\/localhost:9200\/foo_index\/_doc\/XXXXXXXXXXXXXXXXXXXX\r\n<\/code><\/pre>\n<h3>\u83b7\u53d6\u6587\u6863\u6570\u91cf<\/h3>\n<p>\u8ba1\u6570API | Elasticsearch \u53c2\u8003\u8d44\u6599 [7.8] | Elastic<\/p>\n<pre class=\"post-pre\"><code>$ curl -XGET http:\/\/localhost:9200\/foo_index\/_count\r\n<\/code><\/pre>\n<h3>\u641c\u7d22\u6587\u6863<\/h3>\n<p>\u67e5\u8be2DSL | Elasticsearch\u53c2\u8003\u30107.8\u3011|\u5f39\u6027<br \/>\n\u5339\u914d\u67e5\u8be2| Elasticsearch\u53c2\u8003\u30107.8\u3011|\u5f39\u6027<\/p>\n<pre class=\"post-pre\"><code>$ curl -XGET http:\/\/localhost:9200\/foo_index\/_search \\\r\n-H 'Content-Type: application\/json' \\\r\n-d '\r\n{\r\n  \"query\": {\r\n    \"match\": {\r\n      \"foo_message\": \"\u591c\"\r\n    }\r\n  }\r\n}'\r\n<\/code><\/pre>\n<h2>\u8bf7\u53c2\u8003\u76f8\u5173\u8d44\u6599\u3002<\/h2>\n<h3>\u901a\u8fc7Homebrew\u5b89\u88c5Elasticsearch\u3002<\/h3>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">macOS\u5411\u3051\u306b\u3001\u30aa\u30d5\u30a3\u30b7\u30e3\u30eb\u7248Elastic Homebrew\u30bf\u30c3\u30d7\u3092\u30ea\u30ea\u30fc\u30b9 | Elastic Blog<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">Install Elasticsearch on macOS with Homebrew | Elasticsearch Reference [7.8] | Elastic<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">Configuring Elasticsearch | Elasticsearch Reference [7.8] | Elastic<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">GitHub &#8211; elastic\/homebrew-tap: Homebrew tap for the Elastic Stack<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">elasticsearch \u2014 Homebrew Formulae<\/ul>\n<h3>Elasticsearch \u7684 REST API<\/h3>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u57fa\u672c\u6982\u5ff5 | Elasticsearch\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9 [5.4] | Elastic<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30bf\u30a4\u30d7\u30ec\u30b9API\u306b\u79fb\u884c\u3059\u308b\uff1aElasticsearch 7.0\u306e\u5909\u66f4\u70b9 | Elastic Blog<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">REST APIs | Elasticsearch Reference [7.8] | Elastic<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u603b\u7ed3 Homebrew \u3067 Elasticsearch 7 \u3092 macOS \u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b &nbsp;  [&hellip;]<\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-40577","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u5728 macOS \u4e0a\u6784\u5efa Elasticsearch 7 \u5e76\u8fdb\u884c\u5168\u6587\u641c\u7d22 - Blog - Silicon Cloud<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/zh\/blog\/\u5728-macos-\u4e0a\u6784\u5efa-elasticsearch-7-\u5e76\u8fdb\u884c\u5168\u6587\u641c\u7d22\u3002\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u5728 macOS \u4e0a\u6784\u5efa Elasticsearch 7 \u5e76\u8fdb\u884c\u5168\u6587\u641c\u7d22\" \/>\n<meta property=\"og:description\" content=\"\u603b\u7ed3 Homebrew \u3067 Elasticsearch 7 \u3092 macOS \u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b &nbsp; [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/zh\/blog\/\u5728-macos-\u4e0a\u6784\u5efa-elasticsearch-7-\u5e76\u8fdb\u884c\u5168\u6587\u641c\u7d22\u3002\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2024-02-04T14:31:24+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-28T23:04:08+00:00\" \/>\n<meta name=\"author\" content=\"\u6587, \u7fd4\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u6587, \u7fd4\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8-macos-%e4%b8%8a%e6%9e%84%e5%bb%ba-elasticsearch-7-%e5%b9%b6%e8%bf%9b%e8%a1%8c%e5%85%a8%e6%96%87%e6%90%9c%e7%b4%a2%e3%80%82\/\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8-macos-%e4%b8%8a%e6%9e%84%e5%bb%ba-elasticsearch-7-%e5%b9%b6%e8%bf%9b%e8%a1%8c%e5%85%a8%e6%96%87%e6%90%9c%e7%b4%a2%e3%80%82\/\",\"name\":\"\u5728 macOS \u4e0a\u6784\u5efa Elasticsearch 7 \u5e76\u8fdb\u884c\u5168\u6587\u641c\u7d22 - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\"},\"datePublished\":\"2024-02-04T14:31:24+00:00\",\"dateModified\":\"2024-04-28T23:04:08+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/64d5cc7727fffbff2f9a2a8da1de3e5c\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8-macos-%e4%b8%8a%e6%9e%84%e5%bb%ba-elasticsearch-7-%e5%b9%b6%e8%bf%9b%e8%a1%8c%e5%85%a8%e6%96%87%e6%90%9c%e7%b4%a2%e3%80%82\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8-macos-%e4%b8%8a%e6%9e%84%e5%bb%ba-elasticsearch-7-%e5%b9%b6%e8%bf%9b%e8%a1%8c%e5%85%a8%e6%96%87%e6%90%9c%e7%b4%a2%e3%80%82\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8-macos-%e4%b8%8a%e6%9e%84%e5%bb%ba-elasticsearch-7-%e5%b9%b6%e8%bf%9b%e8%a1%8c%e5%85%a8%e6%96%87%e6%90%9c%e7%b4%a2%e3%80%82\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/zh\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u5728 macOS \u4e0a\u6784\u5efa Elasticsearch 7 \u5e76\u8fdb\u884c\u5168\u6587\u641c\u7d22\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/64d5cc7727fffbff2f9a2a8da1de3e5c\",\"name\":\"\u6587, \u7fd4\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/920c3d673e0bccacc98e5e6b7149bb3c22edd8d39cb753e5d7d7e471498118a1?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/920c3d673e0bccacc98e5e6b7149bb3c22edd8d39cb753e5d7d7e471498118a1?s=96&d=mm&r=g\",\"caption\":\"\u6587, \u7fd4\"},\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/author\/wenxiang\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8-macos-%e4%b8%8a%e6%9e%84%e5%bb%ba-elasticsearch-7-%e5%b9%b6%e8%bf%9b%e8%a1%8c%e5%85%a8%e6%96%87%e6%90%9c%e7%b4%a2%e3%80%82\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"\u5728 macOS \u4e0a\u6784\u5efa Elasticsearch 7 \u5e76\u8fdb\u884c\u5168\u6587\u641c\u7d22 - Blog - Silicon Cloud","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/zh\/blog\/\u5728-macos-\u4e0a\u6784\u5efa-elasticsearch-7-\u5e76\u8fdb\u884c\u5168\u6587\u641c\u7d22\u3002\/","og_locale":"zh_CN","og_type":"article","og_title":"\u5728 macOS \u4e0a\u6784\u5efa Elasticsearch 7 \u5e76\u8fdb\u884c\u5168\u6587\u641c\u7d22","og_description":"\u603b\u7ed3 Homebrew \u3067 Elasticsearch 7 \u3092 macOS \u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b &nbsp; [&hellip;]","og_url":"https:\/\/www.silicloud.com\/zh\/blog\/\u5728-macos-\u4e0a\u6784\u5efa-elasticsearch-7-\u5e76\u8fdb\u884c\u5168\u6587\u641c\u7d22\u3002\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2024-02-04T14:31:24+00:00","article_modified_time":"2024-04-28T23:04:08+00:00","author":"\u6587, \u7fd4","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u6587, \u7fd4","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8-macos-%e4%b8%8a%e6%9e%84%e5%bb%ba-elasticsearch-7-%e5%b9%b6%e8%bf%9b%e8%a1%8c%e5%85%a8%e6%96%87%e6%90%9c%e7%b4%a2%e3%80%82\/","url":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8-macos-%e4%b8%8a%e6%9e%84%e5%bb%ba-elasticsearch-7-%e5%b9%b6%e8%bf%9b%e8%a1%8c%e5%85%a8%e6%96%87%e6%90%9c%e7%b4%a2%e3%80%82\/","name":"\u5728 macOS \u4e0a\u6784\u5efa Elasticsearch 7 \u5e76\u8fdb\u884c\u5168\u6587\u641c\u7d22 - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website"},"datePublished":"2024-02-04T14:31:24+00:00","dateModified":"2024-04-28T23:04:08+00:00","author":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/64d5cc7727fffbff2f9a2a8da1de3e5c"},"breadcrumb":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8-macos-%e4%b8%8a%e6%9e%84%e5%bb%ba-elasticsearch-7-%e5%b9%b6%e8%bf%9b%e8%a1%8c%e5%85%a8%e6%96%87%e6%90%9c%e7%b4%a2%e3%80%82\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8-macos-%e4%b8%8a%e6%9e%84%e5%bb%ba-elasticsearch-7-%e5%b9%b6%e8%bf%9b%e8%a1%8c%e5%85%a8%e6%96%87%e6%90%9c%e7%b4%a2%e3%80%82\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8-macos-%e4%b8%8a%e6%9e%84%e5%bb%ba-elasticsearch-7-%e5%b9%b6%e8%bf%9b%e8%a1%8c%e5%85%a8%e6%96%87%e6%90%9c%e7%b4%a2%e3%80%82\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/zh\/blog\/"},{"@type":"ListItem","position":2,"name":"\u5728 macOS \u4e0a\u6784\u5efa Elasticsearch 7 \u5e76\u8fdb\u884c\u5168\u6587\u641c\u7d22"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website","url":"https:\/\/www.silicloud.com\/zh\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/64d5cc7727fffbff2f9a2a8da1de3e5c","name":"\u6587, \u7fd4","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/920c3d673e0bccacc98e5e6b7149bb3c22edd8d39cb753e5d7d7e471498118a1?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/920c3d673e0bccacc98e5e6b7149bb3c22edd8d39cb753e5d7d7e471498118a1?s=96&d=mm&r=g","caption":"\u6587, \u7fd4"},"url":"https:\/\/www.silicloud.com\/zh\/blog\/author\/wenxiang\/"},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8-macos-%e4%b8%8a%e6%9e%84%e5%bb%ba-elasticsearch-7-%e5%b9%b6%e8%bf%9b%e8%a1%8c%e5%85%a8%e6%96%87%e6%90%9c%e7%b4%a2%e3%80%82\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/40577","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/comments?post=40577"}],"version-history":[{"count":2,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/40577\/revisions"}],"predecessor-version":[{"id":83768,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/40577\/revisions\/83768"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/media?parent=40577"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/categories?post=40577"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/tags?post=40577"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}