Hi , i have follow script do aggregation of the production year revenue. However, I dunno how can I use the visualization to present the result. Please help or point me some direction please and thanks.
POST elk_all/sales_daily
{
"code": 2,
"name": "RedTB",
"year": 2018,
"sales": 1000
}
POST elk_all/sales_daily
{
"code": 1,
"name": "BlueTB",
"year": 2018,
"sales": 1000
}
POST elk_all/sales_daily
{
"code": 2,
"name": "RedTB",
"year": 2017,
"sales": 600
}
POST elk_all/sales_daily
{
"code": 1,
"name": "BlueTB",
"year": 2017,
"sales": 920
}
POST elk_all/sales_daily
{
"code": 2,
"name": "RedTB",
"year": 2016,
"sales": 800
}
POST elk_all/sales_daily
{
"code": 1,
"name": "BlueTB",
"year": 2016,
"sales": 900
}
GET elk_all/_search
{
"size": 0,
"query": {
"bool": {
"must": {
"range": {
"year": {
"gte": "2016",
"lte": "2018"
}
}
}
}
},
"aggs": {
"group_by_code": {
"terms": {
"field": "code"
},
"aggs": {
"first_sale": {
"filter": {
"term": {
"year": "2016"
}
},
"aggs": {
"sales_value": {
"max": {
"field": "sales"
}
}
}
},
"mid_sale": {
"filter": {
"term": {
"year": "2017"
}
},
"aggs": {
"sales_value": {
"max": {
"field": "sales"
}
}
}
},
"last_sale": {
"filter": {
"term": {
"year": "2018"
}
},
"aggs": {
"sales_value": {
"max": {
"field": "sales"
}
}
}
},
"filter_positive": {
"bucket_selector": {
"buckets_path": {
"first": "first_sale>sales_value",
"mid": "mid_sale>sales_value",
"last": "last_sale>sales_value"
},
"script": "params.last > params.mid && params.mid < params.first"
}
}
}
}
}
}