Hi, I have documents like the following in the same index pattern:
{
"timestamp": ...
"user_id": "LUCA",
"dealer": 123456789,
"method": "search",
"ip": 1.1.1.1,
"search": "number='123456789'"
}
{
"timestamp": ...
"user_id": "LUCA",
"dealer": 123456789,
"method": "orderEntry",
"ip": 1.1.1.1
}
I need to calculate these 2 values:
ratio = number of searches per dealer / number of orderEntry per dealer
gap = number of searches per dealer - number of orderEntry per dealer
I can do this in dev tools with this query:
{
"size":0,
"aggs":{
"datehistogram":{
"date_histogram":{
"field":"timestamp",
"interval":"day"
},
"aggs":{
"User":{
"terms":{
"field":"user_id.keyword",
"size":10
},
"aggs":{
"search":{
"value_count":{
"field":"search.keyword"
}
},
"termorder":{
"filter":{
"term":{
"method.keyword":"orderEntry"
}
}
},
"ratio":{
"bucket_script":{
"buckets_path":{
"searchcount":"search.value",
"termordercount":"termorder._count"
},
"script":"params.searchcount/params.termordercount"
}
},
"gap":{
"bucket_script":{
"buckets_path":{
"searchcount":"search.value",
"termordercount":"termorder._count"
},
"script":"params.searchcount-params.termordercount"
}
}
}
}
}
}
}
}
I can't find a way to display this in kibana, I tryed to play with the data table with no success
Can anyone help me with this?
Thanks in advance