How to generate candlesticks

i'm trying to add first element's property "open" and last element's property "close" to the inner aggregation.

The document looks as follows:

{ 
  "id": "1b73c03c-182e-4092-bf23-7fb6e2525586", 
  "assetId": 5, 
  "open": 143.345, 
  "close": 143.355, 
  "min": 143.335, 
  "max": 143.355, 
  "tS": "2017-04-10T18:24:00"
}

the query looks like this:

.Aggregations(a => a 
 .DateHistogram("bars", st => st 
   .Field(o => o.TS) 
   .Interval(interval) 
   .MinimumDocumentCount(2) 
   .Aggregations(childAggs => childAggs 
    .Min("min", avg => avg.Field(p => p.Min)) 
    .Max("max", avg => avg.Field(p => p.Max)) ) ) )

need to add aggregation for open which is first element's open property and aggregation for close which is last element's close property.

Does anyone have an idea how to do that?
Thanks in advance

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