ES常用查询

根据编号查询

GET custom/_search
{
  "query": {
    "term": {
      "no": "abc"
    }
  }
}

查询指定的列

GET custom/_search
{
  "_source": ["id", "no"],
  "size": 10000,  
  "query": {
    "ids": {
      "values": [
        1419623, 1419622, 1419621
      ]
    }
  }
}

根据id删除

POST /custom/_delete_by_query
{
  "query": {
    "terms": {
      "_id": [21151]
    }
  }
}

根据id修改某记录的值

POST /custom/_update/13878794
{
  "doc": {
    "playTime": null
  }
}

根据id将某记录的个别字段值删除

POST /custom/_update/13878794
{
  "script": {
    "source": "ctx._source.remove('playTime')"
  }
}

查询索引结构

GET /custom

GET /custom/_mapping

完整索引创建

PUT /my_index
{
  "settings": {
    "number_of_shards": 3,
    "number_of_replicas": 1
  },
  "mappings": {
    "properties": {
      "user_id": { "type": "long" },
      "content": { "type": "text", "analyzer": "ik_max_word" },
      "created_at": { "type": "date" }
    }
  }
}

PUT /{index_name}
{
  "settings": { ... },    # 索引的配置(分片、副本等)
  "mappings": { ... },    # 字段类型和属性定义
  "aliases": { ... }      # 可选,索引别名
}

更新映射(仅允许新增字段)

PUT /{index_name}/_mapping
{
  "properties": {
    "new_field": {
      "type": "keyword"
    }
  }
}

3.2 修改设置(如副本数)

PUT /{index_name}/_settings
{
  "index": {
    "number_of_replicas": 2
  }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值