elasticsearch使用kibana实现基本的增删改查操作

在安装kibana(安装过程详见:https://blog.csdn.net/yanyf2016/article/details/103925273)之后,打开找到Dev Tools

#创建索引
PUT /lib/
{
  "settings": {
    "index":{
      "number_of_shards":5,
      "number_of_replicas":0
    }
  }
}

PUT lib2
#查看索引配置
GET /lib/_settings 

GET /lib2/_settings 

GET _all/_settings
#创建索引之后就可以在索引之下添加文档
#指定id用put
PUT /lib/user/1
{
  "first_name":"jame",
  "last_name":"smith",
  "age":33,
  "about": "I like to collent rock albums",
  "interests":["music"]
}
#不指定id用post,id由elasticsearch生成
POST /lib/user/
{
  "first_name":"jame",
  "last_name":"smith",
  "age":33,
  "about": "I like to collent rock albums",
  "interests":["music"]
}
#查询文档所有信息
GET /lib/user/1
GET /lib/user/_oVuj28Bo8RJqkNDiyCj
#查询文档部分信息
GET /lib/user/1?_source=age,about
#覆盖方式更新
PUT /lib/user/1
{
  "first_name":"jame",
  "last_name":"tom",
  "age":36,
  "about": "I like to collent rock albums",
  "interests":["snook"]
}

#直接更新
POST /lib/user/1/_update
{
  "doc":{
    "age":22
  }
}

#删除文档
DELETE /lib/user/1
#删除索引
DELETE lib2
#批量获取文档全部信息
GET /_mget
{
  "docs":[
    {
      "_index":"lib",
      "_type":"user",
      "_id":1
    },
    {
      "_index":"lib",
      "_type":"user",
      "_id":2
    },
    {
      "_index":"lib",
      "_type":"user",
      "_id":3
    }
  ]
}
#批量获取文档指定信息
GET /_mget
{
  "docs":[
    {
      "_index":"lib",
      "_type":"user",
      "_id":1,
      "_source":"interests"
    },
    {
      "_index":"lib",
      "_type":"user",
      "_id":2,
       "_source":["age","interests"]
    }
  ]
}
#获取相同索引相同类型下的文档
GET /lib/user/_mget
{
  "docs":[
    {
      "_id":1
    },
    {
      "_type":"user",
      "_id":2
    }
  ]
}

#更简单的写法
GET /lib/user/_mget
{
  "ids":["1","2"]
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值