elasticsearch基本概念和CRUD:

基本概念:

ELK 学习笔记之 elasticsearch基本概念和CRUD-LMLPHP

CRUD

创建索引:

curl -XPUT 'http://192.168.1.151:9200/library/' -d '{"settings": {"index": {"number_of_shards": 5,"number_of_replicas": 1}}}'

ELK 学习笔记之 elasticsearch基本概念和CRUD-LMLPHP

查看索引:

curl -XGET 'http://192.168.1.151:9200/library/_settings'

ELK 学习笔记之 elasticsearch基本概念和CRUD-LMLPHP

获取所有索引信息:

curl -XGET 'http://192.168.1.151:9200/_all/_settings'

ELK 学习笔记之 elasticsearch基本概念和CRUD-LMLPHP

创建一个文档:

curl -XPOST 'http://192.168.1.151:9200/library/books/1' -d '{"title": "spark", "name":{"first": "Huang", "last": "Sky"}, "price": "99"}'

ELK 学习笔记之 elasticsearch基本概念和CRUD-LMLPHP

获得文档信息:

curl -XGET 'http://192.168.1.151:9200/library/books/1'

ELK 学习笔记之 elasticsearch基本概念和CRUD-LMLPHP

获得文档的某些字段:

curl -XGET 'http://192.168.1.151:9200/library/books/1?_source=title,price'

ELK 学习笔记之 elasticsearch基本概念和CRUD-LMLPHP

更新文档(覆盖,不推荐):

curl -XPUT 'http://192.168.1.151:9200/library/books/1' -d '{"title": "spark", "name":{"first": "Huang", "last": "Sky"}, "price": "59"}'

ELK 学习笔记之 elasticsearch基本概念和CRUD-LMLPHP

更新文档(推荐):

curl -XPOST 'http://192.168.1.151:9200/library/books/1/_update' -d '{"doc": {"price": "79"}}'

ELK 学习笔记之 elasticsearch基本概念和CRUD-LMLPHP

删除文档:

curl -XDELETE 'http://192.168.1.151:9200/library/books/3'

ELK 学习笔记之 elasticsearch基本概念和CRUD-LMLPHP

删除索引:

curl -XDELETE 'http://192.168.1.151:9200/library'

通过elasticsearch head页面查看信息:

ELK 学习笔记之 elasticsearch基本概念和CRUD-LMLPHP

ELK 学习笔记之 elasticsearch基本概念和CRUD-LMLPHP

05-11 16:00