美文网首页
Elasticsearch 增删改查

Elasticsearch 增删改查

作者: Dramecj | 来源:发表于2019-02-28 21:41 被阅读0次

    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?'
    
    

    相关文章

      网友评论

          本文标题:Elasticsearch 增删改查

          本文链接:https://www.haomeiwen.com/subject/iaaquqtx.html