其他分享
首页 > 其他分享> > ES笔记记录

ES笔记记录

作者:互联网

1 更新操作

POST indexName/_update_by_query
{
  "query": {
    "match_all":{}
  },
  "script": {
    "source": "ctx._source['cloumnName']=1"
  }
}
POST my_index/_update_by_query
{
  "script": {
    "lang": "painless",
    "inline": "ctx._source.new_field_name1= '1111'"
  }
}
# 给索引添加字段
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"
  }
}
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": {}
  }
}

标签:index,catid,记录,笔记,cat,source,field,query,ES
来源: https://blog.csdn.net/ilifei/article/details/121625889