Aggregation count problem

Hello,
I want to display an indicator on kibana, but I can not do it. I explain the situation.
I want to display "the total number of products whose thresholds exceeded the maximum of consumers' cuttof".
we have a product that contains the following elements (idProduct, idConsumer, sillDate, cutoff, libProduct). the relationship between products and consumers is of type (n, n).

the formula to use is: product.stillDate-Max (product.cutoff)> 0

example of given:

product: A1- consumer: C1

{
"IdProduct": "A1",
"IdConsumer", "C1",
"SillDate": "2017-10-23T10: 00: 00Z"
"Cutoff": "2017-10-21T00: 00: 00Z"
"LibProduct", "test"
}

product: A1- consumer: C2

{
"IdProduct": "A1",
"IdConsumer": "C2"
"SillDate": "2017-10-23T10: 00: 00Z"
"Cutoff": "2017-10-22T08: 00: 00Z"
"LibProduct": "test1"
}

product: A1- consumer: C3

{
"IdProduct": "A1",
"IdConsumer": "C3"
"SillDate": "2017-10-23T10: 00: 00Z"
"Cutoff": "2017-10-23T08: 00: 00Z"
"LibProduct": "test2"
}

a product A1 is associated with 3 consumers with 3 cutoffs. the maximum cutoff for product A1 is:
2017-10-23T08: 00: 00Z. So the number is: sum ((2017-10-23T10: 00: 00Z -2017-10-23T08: 00: 00Z)> 0)

The question how can I do this on kibana?
Thank you for your help and I apologize for my level in English

Any help ?

As long as your dates are indexed as dates this should be possible. Kibana uses Lucine Query Syntax

See https://www.elastic.co/guide/en/elasticsearch/reference/5.5/query-dsl-query-string-query.html#_ranges

A search of IdProduct: $PRODUCT_ID AND Cutoff:>$DATE should give you the results you want. Use that query for a chart and bucket by IdConsumer. If I understood you correctly :slight_smile:

-AB

$PRODUCT_ID AND $DATE are the variable ?

For each product i want to get the max cutoff and do product.stillDate-Max (product.cutoff)

Thanks :slight_smile:

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.