elasticsearch基本概念和CRUD:
基本概念:
CRUD:
创建索引:
curl -XPUT 'http://192.168.1.151:9200/library/' -d '{"settings": {"index": {"number_of_shards": 5,"number_of_replicas": 1}}}'
查看索引:
curl -XGET 'http://192.168.1.151:9200/library/_settings'
获取所有索引信息:
curl -XGET 'http://192.168.1.151:9200/_all/_settings'
创建一个文档:
curl -XPOST 'http://192.168.1.151:9200/library/books/1' -d '{"title": "spark", "name":{"first": "Huang", "last": "Sky"}, "price": "99"}'
获得文档信息:
curl -XGET 'http://192.168.1.151:9200/library/books/1'
获得文档的某些字段:
curl -XGET 'http://192.168.1.151:9200/library/books/1?_source=title,price'
更新文档(覆盖,不推荐):
curl -XPUT 'http://192.168.1.151:9200/library/books/1' -d '{"title": "spark", "name":{"first": "Huang", "last": "Sky"}, "price": "59"}'
更新文档(推荐):
curl -XPOST 'http://192.168.1.151:9200/library/books/1/_update' -d '{"doc": {"price": "79"}}'
删除文档:
curl -XDELETE 'http://192.168.1.151:9200/library/books/3'
删除索引:
curl -XDELETE 'http://192.168.1.151:9200/library'
通过elasticsearch head页面查看信息: