elasticsearch 查询语法

查询节点

GET /_cat/nodes?v

查询所有索引

GET /_cat/indices?v

创建索引

PUT  /test_index?pretty

test_index是索引名

查询索引结构

GET /test_index

查询指定索引指定表的记录

GET /test_index/table1/_search
{
  "query": {
    "match_all":{}
  }
}

用简单的查询可以这样

GET /test_index/_search?q=*
GET /test_index/_search?q=name:jane

创建mapping(定义表结构)

PUT /test_index/_mapping/table1
 {
  "properties": {
    "sex":{
      "type":"integer"
    },
    "is_enable": {
      "type":"boolean"
    }
  }
}

插入/更新记录

POST /test_index/table1/1
 {
   "id":1,
   "name":"张四",
   "descriptions":"就是那个传说中的张四",
   "age":80,
   "nickname":"张小四",
   "books":{
     "name":"张小四自传",
     "price":55555
   }
 }

其中:
test_index:索引名
table1:表名
1:id

指定id删除记录

DELETE /test_index/table1/1

批量删除

POST /test_index/table1/_bulk
{"delete":{"_id":"1"}}

清空table1表的记录

POST /test_index/table1/_delete_by_query?conflicts=proceed
{
  "query": {
    "match_all": {}
  }
}

更新数据,只对指定的字段更新

POST /test_index/table1/2/_update
{
  "doc": {
    "name": "Jane Doe"
  }
}
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值