I'm using olivere's v.5 elasticsearch library - https://godoc.org/github.com/olivere/elastic
Trying to do something similar to this post which uses the v.2 library - How to search in elasticsearch with Go filtering results by time frames
But 'NewRangeFilter' and 'NewFilteredQuery' are not available in v.5. There is a 'DateRange' API in v.5 (https://godoc.org/github.com/olivere/elastic#Aggregations.DateRange) that I can call from an Aggregation, but it takes in a string, so I don't know what I'm supposed to pass in.
This is what I've tried so far to build an aggregation. After that, I'm not sure what to pass into the DateRange function. I have an index called 'tmpindex' and type called 'user' and each document has a 'timestamp' property which is an integer.
timeline := elasticClient.NewTermsAggregation().Field("timestamp").Size(10).OrderByCountDesc()
searchResult, err := elasticClient.Search().
Index("tmpindex"). // search in index "tmpindex"
Aggregation("timeline", timeline).
From(0).Size(10). // take documents 0-9
Pretty(true). // pretty print request and response JSON
Do(context.Background()) // execute
if err != nil {
return err
}