2-Elasticsearch基础入门-增删改查并发控制

一起来玩Elasticsearch,加我微信:wx1250134974

Elasticsearch认证复习准备

https://www.elastic.co/guide/cn/elasticsearch/guide/current/getting-started.html

 

 

##索引文档、更新文档(id可以自定义也可以使用默认生成的)

PUT /website/blog/123

{

  "title": "My first blog entry",

  "text":  "Just trying this out...",

  "date":  "2014/01/01"

}

 

 

POST /website/blog/

{

  "title": "My second blog entry",

  "text":  "Still trying this out...",

  "date":  "2014/01/01"

}

 

 

##取回一个文档

GET /website/blog/123?pretty

 

 

##创建新文档而不是覆盖已有文档

PUT /website/blog/123/_create

{

  "title": "My first blog entry",

  "text":  "Just trying this out...",

  "date":  "2014/01/01"

}

 

##删除文档

DELETE /website/blog/123

 

 

##并发控制更新

PUT /website/blog/123?version=1

{

  "title": "My first blog entry",

  "text":  "Just trying this out...",

  "date":  "2014/01/01"

}

 

 

##部分更新

POST /website/blog/123/_update

{

   "doc" : {

      "tags" : [ "testing" ],

      "views": 0,

      "date":  "2014/01/01"

   }

}

 

##更新已有映射(只能增加新的域映射,不能更新现有的域映射)

PUT /website/blog/_mapping

{

  "properties" : {

    "tag" : {

      "type" :    "text",

      "index":    "not_analyzed"

    }

  }

}

 

 

##一次获取多个文档

GET /_mget

{

   "docs" : [

      {

         "_index" : "website",

         "_type" :  "blog",

         "_id" :    123

      },

      {

         "_index" : "website",

         "_type" :  "pageviews",

         "_id" :    123,

         "_source": "views"

      }

   ]

}

 

 

 

 

GET /website/blog/_mget

{

   "ids" : [ "123", "1" ]

}

 

 

 

##批量操作

https://www.elastic.co/guide/cn/elasticsearch/guide/current/bulk.html

POST /_bulk

{ "delete": { "_index": "website", "_type": "blog", "_id": "123" }}

{ "create": { "_index": "website", "_type": "blog", "_id": "123" }}

{ "title":    "My first blog post" }

{ "index":  { "_index": "website", "_type": "blog" }}

{ "title":    "My second blog post" }

{ "update": { "_index": "website", "_type": "blog", "_id": "123", "_retry_on_conflict" : 3} }

{ "doc" : {"title" : "My updated blog post"} }

 

 

 

一起来玩Elasticsearch,加我微信:wx1250134974

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值