【kibana】

1.put创建文档 

指定的ID,就是文档的_id值。可以根据文档的ID,更新文档的元数据。
--但是POST 创建的文档_id是个UUID值,根据文档的:_id的UUID
--无法操作成功。

{
  "took" : 2,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 3,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "myindex15",
        "_type" : "_doc",
        "_id" : "1",
        "_score" : 1.0,
        "_source" : {
          "id" : 1,
          "name" : "zhangsan",
          "city" : "chengdu",
          "course" : "语文",
          "teacher" : "李四",
          "pxdate" : "riqi"
        }
      },
      {
        "_index" : "myindex15",
        "_type" : "_doc",
        "_id" : "2",
        "_score" : 1.0,
        "_source" : {
          "id" : 2,
          "name" : "zhangsan",
          "city" : "chengdu",
          "course" : "语文",
          "teacher" : "李五",
          "pxdate" : "riqi"
        }
      },
      {
        "_index" : "myindex15",
        "_type" : "_doc",
        "_id" : "3",
        "_score" : 1.0,
        "_source" : {
          "id" : 3,
          "name" : "zhangsan",
          "city" : "chengdu",
          "course" : "语文",
          "teacher" : "李六",
          "pxdate" : "riqi"
        }
      }
    ]
  }
}

2.POST创建文档

post myindex15/_doc 
{
  "id":4,
  "name":"力气",
  "city":"shanghai",
  "teacher":"zhagnyu"
}

get myindex15/_search
{
  "took" : 596,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 4,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "myindex15",
        "_type" : "_doc",
        "_id" : "1",
        "_score" : 1.0,
        "_source" : {
          "id" : 1,
          "name" : "zhangsan",
          "city" : "chengdu",
          "course" : "语文",
          "teacher" : "李四",
          "pxdate" : "riqi"
        }
      },
      {
        "_index" : "myindex15",
        "_type" : "_doc",
        "_id" : "2",
        "_score" : 1.0,
        "_source" : {
          "id" : 2,
          "name" : "zhangsan",
          "city" : "chengdu",
          "course" : "语文",
          "teacher" : "李五",
          "pxdate" : "riqi"
        }
      },
      {
        "_index" : "myindex15",
        "_type" : "_doc",
        "_id" : "3",
        "_score" : 1.0,
        "_source" : {
          "id" : 3,
          "name" : "zhangsan",
          "city" : "chengdu",
          "course" : "语文",
          "teacher" : "李六",
          "pxdate" : "riqi"
        }
      },
      {
        "_index" : "myindex15",
        "_type" : "_doc",
        "_id" : "iz6wXZABmMobXH8At5mW",
        "_score" : 1.0,
        "_source" : {
          "id" : 4,
          "name" : "力气",
          "city" : "shanghai",
          "teacher" : "zhagnyu"
        }
      }
    ]
  }
}

POST插入的文档的_id='iz6wXZABmMobXH8At5mW';

3.总结 

在执行添加字段,删除字段等操作时,PUT方式指定的_ID值的方式更方便。
POST方式创建的文档,无法具体指定文档的_iD值,进行更新。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值