From b851b0c31b5a18704064470d2e91053d18d292f1 Mon Sep 17 00:00:00 2001 From: shaoying Date: Thu, 13 Aug 2020 01:05:20 +0800 Subject: [PATCH] add es --- misc/es/es.go | 44 ++++++++++++++++++++++++++++++++++++++++++++ misc/es/es.shy | 28 ++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 misc/es/es.go create mode 100644 misc/es/es.shy diff --git a/misc/es/es.go b/misc/es/es.go new file mode 100644 index 00000000..7ad1de33 --- /dev/null +++ b/misc/es/es.go @@ -0,0 +1,44 @@ +package es + +import ( + "net/http" + "path" + "runtime" + + ice "github.com/shylinux/icebergs" + kit "github.com/shylinux/toolkits" + + "github.com/shylinux/icebergs/base/cli" + "github.com/shylinux/icebergs/base/nfs" + "github.com/shylinux/icebergs/base/web" + "github.com/shylinux/icebergs/core/code" +) + +const ES = "es" + +var Index = &ice.Context{Name: ES, Help: "搜索", + Configs: map[string]*ice.Config{ + ES: {Name: ES, Help: "搜索", Value: kit.Data( + "windows", "https://elasticsearch.thans.cn/downloads/elasticsearch/elasticsearch-7.3.2-windows-x86_64.zip", + "darwin", "https://elasticsearch.thans.cn/downloads/elasticsearch/elasticsearch-7.3.2-darwin-x86_64.tar.gz", + "linux", "https://elasticsearch.thans.cn/downloads/elasticsearch/elasticsearch-7.3.2-linux-x86_64.tar.gz", + )}, + }, + Commands: map[string]*ice.Command{ + ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {}}, + ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {}}, + + ES: {Name: "es 安装:button", Help: "搜索", Action: map[string]*ice.Action{ + "install": {Name: "install", Help: "安装", Hand: func(m *ice.Message, arg ...string) { + name := path.Base(m.Conf(ES, kit.Keys("meta", runtime.GOOS))) + msg := m.Cmd(web.SPIDE, "dev", "cache", http.MethodGet, m.Conf(ES, kit.Keys("meta", runtime.GOOS))) + m.Cmdy(nfs.LINK, path.Join("usr/install/", name), msg.Append("file")) + m.Option(cli.CMD_DIR, "usr/install") + m.Cmd(cli.SYSTEM, "tar", "xvf", name) + }}, + }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }}, + }, +} + +func init() { code.Index.Register(Index, nil) } diff --git a/misc/es/es.shy b/misc/es/es.shy new file mode 100644 index 00000000..c8b8d108 --- /dev/null +++ b/misc/es/es.shy @@ -0,0 +1,28 @@ +chapter "ElasticSearch" +refer ` +官网 https://www.elastic.co/cn/elasticsearch/ +源码 https://github.com/elastic/elasticsearch +文档 https://www.elastic.co/guide/index.html +安装 https://www.elastic.co/guide/en/elasticsearch/reference/current/install-elasticsearch.html +简介 https://www.jianshu.com/p/403c9d5b1463 +入门 https://www.cnblogs.com/sunsky303/p/9438737.html +` +section 下载 +refer ` +windows https://elasticsearch.thans.cn/downloads/elasticsearch/elasticsearch-7.3.2-windows-x86_64.zip +darwin https://elasticsearch.thans.cn/downloads/elasticsearch/elasticsearch-7.3.2-darwin-x86_64.tar.gz +linux https://elasticsearch.thans.cn/downloads/elasticsearch/elasticsearch-7.3.2-linux-x86_64.tar.gz +` + +section 启动 +spark shell ` +$ tar xvf elasticsearch-7.3.2-linux-x86_64.tar.gz +$ cd elasticsearch-7.3.2 +$ ./bin/elasticsearch +` + +section 创建索引 +spark shell ` +$ curl http://localhost:9200 +$ curl -XPUT "localhost:9200/index_test" +`