码迷,mamicode.com
首页 > 其他好文 > 详细

ElasticSearch _bulk和_mget

时间:2021-03-11 20:50:46      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:create   first   xxx   查找   筛选   索引   根据   delete   name   

_bulk api

POST /_bulk

批量操作

POST _bulk
{ "index" : { "_index" : "movies", "_id" : "1" } }
{ "year" : 1994 }
{ "delete" : { "_index" : "movies", "_id" : "1" } }
{ "delete" : { "_index" : "movies1", "_id" : "1" } }
{ "create" : { "_index" : "movies", "_id" : "1" } }
{ "year" : "1994" }
{ "update" : {"_id" : "1", "_index" : "movies"} }
{ "doc" : {"name" : "1"} }

POST //_bulk

批量操作 指定索引

POST movies/_bulk
{ "index" : {  "_id" : "2" } }
{ "year" : 1994 }
{ "delete" : {  "_id" : "2" } }
{ "create" : { "_id" : "2" } }
{ "year" : "19924" }
{ "update" : {"_id" : "2"} }
{ "doc" : {"name" : "XXXX2"} }

_mget

GET /_mget 和 GET //_mget

简单的根据id 查找
GET _mget
{
  "docs":[
    {
      "_index":"movies",
      "_id":1
    },  {
      "_index":".kibana-event-log-7.10.2-000001",
      "_id":1
    }
    ]
}

结果:
{
  "docs" : [
    {
      "_index" : "movies",
      "_type" : "_doc",
      "_id" : "1",
      "_version" : 16,
      "_seq_no" : 9779,
      "_primary_term" : 10,
      "found" : true,
      "_source" : {
        "year" : "1994",
        "name" : "1"
      }
    },
    {
      "_index" : ".kibana-event-log-7.10.2-000001",
      "_type" : "_doc",
      "_id" : "1",
      "found" : false
    }
  ]
} 
筛选源
GET _mget
{
  "docs":[
    {
      "_index":"movies",
      "_id":1,
      "_source":["year"]
    },
    {
      "_index":"movies",
      "_id":15061,
      "_source": {
        "include": [ "year","user" ],
        "exclude": [ "user.full_name" ]
      }
    }
  ]
}

结果
{
  "docs" : [
    {
      "_index" : "movies",
      "_type" : "_doc",
      "_id" : "1",
      "_version" : 16,
      "_seq_no" : 9779,
      "_primary_term" : 10,
      "found" : true,
      "_source" : {
        "year" : "1994"
      }
    },
    {
      "_index" : "movies",
      "_type" : "_doc",
      "_id" : "15061",
      "_version" : 1,
      "_seq_no" : 9784,
      "_primary_term" : 10,
      "found" : true,
      "_source" : {
        "year" : 1994,
        "user" : {
          "last_name" : "jiayue",
          "first_name" : "bi"
        }
      }
    }
  ]
}


ElasticSearch _bulk和_mget

标签:create   first   xxx   查找   筛选   索引   根据   delete   name   

原文地址:https://www.cnblogs.com/roinbi/p/14515674.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!