ElasticSearch基础交互该如何分析
ElasticSearch基础交互该如何分析,很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。
RESTful API with JSON over HTTP
创建索引
PUT http://127.0.0.1:9200/people
{"setting":{"number_of_shards":5,"number_of_replicas":1},"mappings":{"man":{"properties":{"name":{"type":"text"},"country":{"type":"keyword"},"age":{"type":"integer"},"date":{"type":"date","format":"yyyy-MM-ddHH:mm::ss||yyyy-MM-dd||epoch_millis"}}}}}
创建结构
结构化创建 需要利用mappings 结构化关键词。
POST http://127.0.0.1:9200/book/cs/_mappings
{"cs":{"properties":{"title":{"type":"text"}}}}
插入数据
1.指定文档ID插入
PUT http://127.0.0.1:9200/people/man/1
{"name":"张仁杰","country":"China","age":30,"date":"1987-06-01"}
2.自动产生文档ID插入
POST http://127.0.0.1:9200/people/man
{"name":"张惠","country":"China","age":28,"date":"1990-11-01"}
修改数据
1.直接修改
POST http://127.0.0.1:9200/people/man/1/_update
{"doc":{"name":"Jack","age":31}}
POST http://127.0.0.1:9200/people/man/1/_update
{"script":{"lang":"painless","inline":"ctx._source.age-=10"}}
{"script":{"lang":"painless","inline":"ctx._source.age=params.age","params":{"age":"100"}}}
删除操作
1.删除文档
DELETE http://127.0.0.1:9200/people/man/1
2.删除索引
DELETE http://127.0.0.1:9200/people
看完上述内容是否对您有帮助呢?如果还想对相关知识有进一步的了解或阅读更多相关文章,请关注亿速云行业资讯频道,感谢您对亿速云的支持。