关于ES安装的流程

  1. 下载ES
    wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.8.0.tar.gz
    解压:Tar -xzf elasticsearch-6.8.0.tar.gz
  2. 创建esuser用户,es不建议使用root用户启动,所以先新建一个用户
    当然也可以强制root用户启动:bin/elasticsearch -Des.insecure.allow.root=true
    useradd esuser //创建用户
    passwd esuser //设置密码
    chown -R esuser elasticsearch-6.8.0/  //赋予用户es权限
    sudo chmod -R 777 某一目录
    su esuser  //切换es用户
  3. 安装插件,我这里安装的es-sql和es-ik分词器
    安装es-sql插件 从github上下载的,有时候会连接超时,多试几次,本地安装总报错,放弃了,可以从别的渠道下载
    ./elasticsearch-plugin install https://github.com/NLPchina/elasticsearch-sql/releases/download/6.8.0.0/elasticsearch-sql-6.8.0.0.zip
    安装es-ik分词器插件,同上
    ./elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.8.0/elasticsearch-analysis-ik-6.8.0.zip
  4. 启动es:./elasticsearch -d # 后台方式启动
  5. 创建索引并设置mapping映射,这里面的"analyzer":"douhao"是我自定义的一个分词器,下面会配置
    put 127.0.0.1:9200/test
    {
        "mappings": {
            "test": {
                "properties": {
                    "businessId": {
                        "type": "long"
                    },
                    "content": {
                        "type": "text",
                        "fields": {
                            "keyword": {
                                "type": "keyword",
                                "ignore_above": 256
                            }
                        },
                        "analyzer":"ik_max_word"
                    },
                    "employeeIds": {
                        "type": "text",
                        "analyzer":"douhao"
                    },
                    "endTime": {
                        "type": "long"
                    },
                    "updateTime": {
                        "type": "long"
                    }
                }
            }
        },
        "settings":{
            "analysis":{
                "analyzer": {
                    "douhao": {
                    "pattern":",",
                        "type":"pattern"
                    }
                }
            }
        }
    }
    
    ​
    /添加逗号分隔的分词器
    put 127.0.0.1:9200/test/test/_settings
    {
        "settings":{
            "analysis":{
                "analyzer": {
                    "douhao": {
                    "pattern":",",
                        "type":"pattern"
                    }
                }
            }
        }
    }
    
    ​

6. 就可以同步数据了。

es的DSL查询语法牛逼是牛逼,但是入门比较难,东西太多。所以我使用了es-sql,虽说查询没有DSL的功能强大,但是也不赖,比较适合会mysql数据库查询的同学。

简单记录一下,以备不时之需。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值