ES笔记记录

1 更新操作

  • 1 更新索引(indexName)下某个字段(cloumnName)的值
POST indexName/_update_by_query
{
  "query": {
    "match_all":{}
  },
  "script": {
    "source": "ctx._source['cloumnName']=1"
  }
}
  • 2 更新索引(indexName)下某个字段(cloumnName)的值
POST my_index/_update_by_query
{
  "script": {
    "lang": "painless",
    "inline": "ctx._source.new_field_name1= '1111'"
  }
}
  • 3 添加字段
# 给索引添加字段
PUT indexName/_mapping/indexTypeName
{
  "properties": {
    "new_field_name1": {
      "type": "keyword"
    },
    "new_field_name2": {
      "type": "keyword"
    },
    "HUMIDITY": {
      "type": "object",
      "enabled": false
    }
  }
}

2 系统配置

  • 参数设置<最大返回记录数>
PUT /index_cat/_settings
{ "index" : { "max_result_window" : 500000}}

3 查询

  • 根据查询条件修改字段:
POST index_cat/_update_by_query
{
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "iscat":2
          }
        }
      ]
    }
  },
  "script": {
    "source": "ctx._source['iscat']=0"
  }
}
  • list入参聚合案例 “catid”: [ “001”,“002” ]
GET index_cat/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "bool": {
            "should": [
              {
                "terms": {
                  "catid": [
                    "001","002"
                  ]
                }
              }
            ]
          }
        }
      ]
    }
  },
  "size": 0,
  "aggs": {
    "general_agg_key": {
      "composite": {
        "sources": [
          {
            "catid": {
              "terms": {
                "field": "catid"
              }
            }
          },
          {
            "is_cat": {
              "terms": {
                "field": "is_cat"
              }
            }
          }
        ],
        "size": 1000000
      }
    }
  }
}
  • 查询所有
GET index_cat/_search
{
  "query": {
    "match_all": {}
  }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值