Elasticsearch是一个基于Lucene的搜索服务器。它提供了一个分布式多用户能力的全文搜索引擎,基于RESTful web接口。Elasticsearch是用Java语言开发的,并作为Apache许可条款下的开放源码发布,是一种流行的企业级搜索引擎。Elasticsearch用于云计算中,能够达到实时搜索,稳定,可靠,快速,安装使用方便。
curl操作:会比较麻烦,先使用这种方式增删改查
Kibana操作ES: 提供简化的工具
写入数据
[root@master ~]# curl -u elastic:hahashen -X PUT http://192.168.20.41:9200/hahashen/_doc/1 -H 'Content-Type: application/json' -d '{"name": "hahashen", "age": 30}'
[root@master ~]# curl -u elastic:hahashen -X PUT http://192.168.20.41:9200/hahashen/_doc/1|python -m json.tool
写入数据随机ID
[root@master ~]# curl -u elastic:hahashen -X POST http://192.168.20.41:9200/hahashen/_doc -H 'Content-Type: application/json' -d '{"name": "hahashen", "age": 25}'
更新数据
[root@master ~]# curl -u elastic:hahashen -X POST http://192.168.20.41:9200/hahashen/_update/1 -H 'Content-Type: application/json' -d '{"doc":{"age": 20}}'
删除数据
[root@master ~]# curl -u elastic:hahashen -X DELETE http://192.168.20.41:9200/hahashen/_doc/1
[root@master ~]# curl -u elastic:hahashen -X DELETE http://192.168.20.41:9200/hahashen/_doc/1
{"_index":"hahashen","_type":"_doc","_id":"1","_version":4,"result":"deleted","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":4,"_primary_term":1}
删除整个索引
[root@master ~]# curl -u elastic:hahashen -X DELETE http://192.168.20.41:9200/hahashen
{"acknowledged":true}