Elasticsearch 增删改查

1、索引的创建和查询

curl -H "Content-Type:application/json;charset=utf-8"  -XPUT 'http://localhost:9200/student_info'

curl -H "Content-Type:application/json;charset=utf-8"  -XPOST 'http://localhost:9200/student_info/_search?pretty' 

2、索引的mapping导入和查询

curl -H "Content-Type:application/json;charset=utf-8" -XPUT 'http://localhost:9200/student_info/doc/_mapping?'  -d  '{"doc":{"date_detection":false,"properties":{"name":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"age":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"mobile_phone":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}}}}'

curl -H "Content-Type:application/json;charset=utf-8" -XGET 'http://localhost:9200/student_info/_mapping?'

3、索引的删除

curl -H "Content-Type:application/json;charset=utf-8" -XDELETE 'http://localhost:9200/student_info?'

4、文档的插入

curl -H "Content-Type:application/json;charset=utf-8"  -XPOST  'http://localhost:9200/student_info/doc?' -d  '{ "name" : "张三", "age" : "21岁", "mobile_phone" : "1724563120"} ' 

5、文档的查询

curl -H "Content-Type:application/json;charset=utf-8"  -XPOST 'http://localhost:9200/student_info/_search?pretty' -d '{"query":{"term" : {"mobile_phone":"1724563120"}}}'

6、文档的删除

curl -H "Content-Type:application/json;charset=utf-8" -XDELETE 'http://localhost:9200/student_info/doc/_id?'

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容