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":{
}
}
}
}
}
}
es kibana操作
于 2023-02-02 21:52:48 首次发布