elasticsearch - Drawing "opened count" over time given open-event and close-event documents -


i have documents modeling creation of ticket, such as:

{     "number": 12,     "created_at": "2015-07-01t12:16:17z",     "closed_at": null,     "state": "open" } 

at point in future, second document models closing event:

{     "number": 12,     "created_at": "2015-07-01t12:16:17z",     "closed_at": "2015-07-08t8:12:42z",     "state": "closed" } 

problem: want draw history of opened tickets. in example above, i'd ticket number 12 contribute count on whole 2015-07-01 2015-07-08 timespan. tried:

  • bucketing date_histogram seems able give number of tickets created or closed on given date bucket.
  • scripted metrics seem allow me change metric computation, not particular bucketing of document.

this first day playing elastic search , kibana might missing obvious. especially, cannot tell if buckets act partitions (hence if document can in single bucket), , hence if problem can solved creating additional documents each datapoint want appear on graph.

additional note: have control on feeding process , schema if storing additional data can help, i'd avoid doing if possible.

though thats not big deal , either mantain hashing on basis of dates, or keep

created_at

as grouping key documents made on day , can distinguish , query them want !!


Comments