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": {}
}
}
标签:index,catid,记录,笔记,cat,source,field,query,ES 来源: https://blog.csdn.net/ilifei/article/details/121625889