es kibana操作

GET t_iot_productout_hours_ts/_search?size=40
{
  "query": {
    "match_all": {}
  }
}

#查询
GET product/_search?size=40
{
  "query": {
    "term": {
      "value": "VALUE"
    }
  }
}

GET t_iot_productout_hours_ts/_search?size=40
{
  "query": {
    "range": {
      "reportTime":{
        "gte":456456456456460,
        "lte":456456456456467
      }
    }
  }
}

#多条件查询 最大值,最小值,求和
GET t_iot_productout_hours_ts/_search?size=40
{
  "query": {
    "bool": {
		"filter":[
			{
			 "range"{
				 "reportTime":{
					"gte":456456456456460,
					"lte":456456456456467
				 }
			 }
			}
		],
		"must":[
			{
				"match":{
					"v":227
				},
				"match":{
					"reportType":1
				}
			}
		]
    }
  },
 "aggs":{
	"ageSum":{
		"sum":{
			"field":"messageCount"
		}
	}
 } 
}

#排序查询
GET t_iot_productout_hours_ts/_search?size=40
{
  "query": {
    "bool": {
		"filter":[
			{
			 "range"{
				 "reportTime":{
					"gte":456456456456460,
					"lte":456456456456467
				 }
			 }
			}
		]
    }
  },
 "sort":{
	"count":{
		"order":"desc"
	}
 } 
}

#查表结构
GET t_iot_productout_hours_ts/_mapping


#删除表数据  根据id
DELETE t_iot_productout_hours_ts/_doc/456456465

#删除表数据   条件
POST t_iot_productout_hours_ts/_doc/_delete_by_query
{
  "query": {
    "term": {
      "count": "65"
    }
  }
}

#删除表数据   全部
POST t_iot_productout_hours_ts/_doc/_delete_by_query
{
  "query": {
    "match_all": {}
  }
}



#创建 index
PUT t_iot_productout_hours_ts

#删除表
DELETE t_iot_productout_hours_ts

#修改表数据  根据id
POST ttt/_update/456456465
{
  "doc":{
    "thingId":"456456456456465"
  }
}

#添加表数据
POST t_iot_productout_hours_ts/_doc/4564564655
{
  "count":65,
  "machineSn":"456456456456465",
  "reportTime":456456456456467,
  "siteId":23,
  "thingId":"456456456456465"
}


#建表结构
PUT t_iot_productout_hours_ts
{
  "settings":{
    "number_of_shards":5,
    "number_of_replicas":1
  },
  "mappings":{
    "properties":{
      "count":{
        "type":"long"
      },
      "machineSn":{
        "type":"long"
      },
      "reportTime":{
        "type":"long"
      },
      "siteId":{
        "type":"long"
      },
      "thingId":{
        "thingId":"long"
      }
    }
  }
}

#建表结构
PUT db_wc 
{
  "mappings":{
    "properties":{
      "stu_age":{
        "type":"integer"
      },
      "stu_name":{
        "type":"keyword"
      },
      "stu_desc":{
        "type":"text"
      }
    }
  }
}

#给已有 index 添加 mapping
PUT t_iot_productout_hours_ts/_mapping
{
  "properties":{
    "emp_name":{
      "type":"keyword"
    },
    "emp_age":{
      "type":"integer"
    }
  }
}

#查看模板
GET _index_template/chain_template

#建表结构模板
PUT  _index_template/chain_template
{
	"index_patterns":"t_iot_data_ts_*",
	"template":{
		"settings":{
			"number_of_shards":5,
			"number_of_replicas":1,
			"opendistro.index_state_management.policy_id":"delete_chain_policy",
			"max_result_window":"200000000"
		},
		"mappings":{
			"properties":{
			  "stu_age":{
				"type":"integer"
			  },
			  "stu_name":{
				"type":"keyword"
			  },
			  "stu_desc":{
				"type":"text"
			  }
			}
		}		
	}
}

#建表结构模板
PUT _template/t_iot_data_ts_template
{
  "index_patterns": "t_iot_data_ts_*",
  "settings": {
    "number_of_shards": 5,
    "number_of_replicas": 1,
    "index.lifecycle.name": "delete_chain_policy",
    "max_result_window": "200000000"
  },
  "mappings": {
    "properties": {
      "stu_age": {
        "type": "integer"
      },
      "stu_name": {
        "type": "keyword"
      },
      "stu_desc": {
        "type": "text"
      }
    }
  }
}


#删表结构模板
DELETE _index_template/chain_template


#设定生命周期
PUT /_ilm/policy/article_ilm_policy(自定义生命周期名称)
{
    "policy":{
        "phases":{
            "hot":{
                "actions":{
                    "rollover":{
                        "max_docs":"50000000"(最大文章数上限)
                    }
                }
            },
            "warm":{
                "min_age":"15d",
                "actions":{
                    "allocate":{
                        "include":{
                            "box_type":"warm"
                        },
                        "number_of_replicas":0
                    },
                    "forcemerge":{
                        "max_num_segments":1
                    }
                }
            },
            "cold":{
                "min_age":"30d",
                "actions":{
                    "allocate":{
                        "include":{
                            "box_type":"cold"
                        }
                    }
                }
            },
            "delete":{
                "min_age":"60d",
                "actions":{
                    "delete":{
 
                    }
                }
            }
        }
    }
}




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值