ElasticSearch 通过 Kibana 与 ElasticSearch-head 完成增删改查
本文为博主原创,未经允许不得转载:
1. 安装并配置 elasticSearch ,kibana, elasticsearch-head
docker 安装 ElasticSearch 和 Kibana : https://www.cnblogs.com/zjdxr-up/p/15358396.html
linux 通过docker安装 elasticsearch-head : https://www.cnblogs.com/zjdxr-up/p/15368569.html
2. 打开 kibana 界面,右侧选择 devtools - > console
2.1 新增索引数据:
PUT lagou { "settings":{ "index":{ "number_of_shards":5, "number_of_replicas":1 } } }
2. 2 通过 elasticsearch -head 查看索引数据
3. 保存文档到索引中:
POST lagou/job/ { "title":"java架构师", "salary_min":30000, "city":"上海", "company":{ "name":"美团", "company_addr":"北京市软件园" }, "publish_date":"2017-4-16", "comments":20 } PUT lagou/job/1 { "title":"python分布式爬虫开发", "salary_min":15000, "city":"北京", "company":{ "name":"百度", "company_addr":"北京市软件园" }, "publish_date":"2017-4-16", "comments":15 }
kibana 操作界面如图:
通过 elasticsearch-head 查看:
4. 修改文档:
PUT lagou/job/1 { "title":"linux运维工程师", "salary_min":10000, "city":"广州", "company":{ "name":"腾讯", "company_addr":"广州软件园" }, "publish_date":"2017-4-12", "comments":21 }
5.查看文档‘
可以通过 elasticsarch-head 查看,也可以使用 GET 命令查看:
GET lagou/job/1
6. 删除文档:
#删除 分为三种删除
#删除一条记录(文章) : DELETE lagou/job/1
#删除一个type(表) : DELETE lagou/job
#删除整个 index (库) : DELETE lagou