欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

elasticsearch 操作

程序员文章站 2022-07-09 19:09:14
...
#配置数据
PUT lagou
{
  "settings": {
    "index": {
      "number_of_shards":5,
      "number_of_replicas":1
    }
  }
}
#获取settings
GET lagou/_settings
GET _all/_settings
GET .kibana,lagou/_settings
GET _settings

#更新settings
PUT lagou/_settings
{
  "number_of_replicas": 2
}

#获取索引信息
GET _all
GET lagou

#保存文档
POST lagou/job/1
{
  
}
POST lagou/job/
{}

#获取信息
GET lagou/job/1

GET lagou/job/1?_source=title
GET lagou/job/1?_source=title,city
GET lagou/job/1?_source

#修改文档  
PUT lagou/job/1 #覆盖
{}

POST lagou/job/1/_update #增量 更新
{
  "doc":{
    "comments":20
  }
}

#删除
DELETE lagou/job/1 #删除文档
DELETE lagou/job  #删除type  似乎不支持
DELETE lagou   #删除索引

#_mget简单使用
GET _mget
{
  "docs":[{
    "_index":testdb,
    "_tpye":job1,
    "id":1,
  },
  {"_index":testdb,
    "_tpye":job2,
    "id":2
  }
  ]
}

GET testdb/_mget
{
    "docs":[
  { 
    "_tpye":job1,
    "id":1,
  },
  {
    "_tpye":job2,
    "id":2
  }
  ]
}

GET testdb/job1/_mget
{
  
    "docs":[
  { 
    "id":1,
  },
  {
    "id":2
  }
  ]
}

GET testdb/job1/_mget
{
  "ids":[1,2]
}

POST _bulk
{"index":{"_index":xx,...}}
{数据}

{"delete":{}}

{"create":{}}
{数据}

{"update":{}}
{"docs":{}}