elasticSearch简单入门

安装

# 新建docker-elasticsearch目录 $ mkdir docker-elasticsearch # 进入docker-elasticsearch目录 $ docker-elasticsearch # 新建config文件夹并修改权限 $ mkdir config && chmod 777 -R config # 新建data文件夹 $ mkdir data && chmod 777 -R data # 写入配置到config目录下的elasticsearch.yml中 $ echo "http.host: 0.0.0.0" >> config/elasticsearch.yml

编写docker-compose.yml文件
version: '3' services: elasticsearch: image: elasticsearch:7.10.1 container_name: elasticsearch restart: always ports: - 9200:9200 - 9300:9300 environment: - "ES_JAVA_OPTS=-Xms64m -Xmx128m" - discovery.type=single-node volumes: - ./config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml - ./data:/usr/share/elasticsearch/data - ./data/plugins:/usr/share/elasticsearch/data/plugins

【elasticSearch简单入门】安装好了以后在浏览器输入HOST:9200, 显示以下界面, 说明安装成功了
elasticSearch简单入门
文章图片

安装kibana
version: '2' services: kibana: container_name: kibana image: kibana:7.10.1 ports: - "5601:5601" restart: always environment: - ELASTICSEARCH_HOSTS=http://192.168.4.5:9200

elasticsearch基本操作 插入数据(PUT, POST)
PUT /account/_doc/1 { "name": "Felix", "age": 18, "company": [ { "name": "BFKJ", "address": "LIUZHOU" }, { "name": "aliyun", "address": "hangzhou" } ] }

// 该方法不需要指定id, 会默认生成一个随机id POST user/_doc { "name": "Felix", "company": "bfkj" }// 没有数据就插入, 有数据就报错 POST user/_create/1 { "name": "Felix", "company": "bfkj" }

获取数据

    推荐阅读