It worked for me with the following data and config:
curl -XPOST 'http://localhost:9200/test3' -d '{
"settings" : {
"number_of_shards" : 1
},
"mappings" : {
"test" : {
"properties" : {
"start_date" : { "type" : "date"},
"end_date" : { "type" : "date"},
"duration" : { "type" : "integer"}
}
}
}
}'
curl -XPUT 'http://localhost:9200/test3/test/1' -d '{
"start_date" : "2015-08-23T00:01:00",
"end_date" : "2015-08-23T14:02:00",
"duration" : 1
}'
curl -XPUT 'http://localhost:9200/test3/test/2' -d '{
"start_date" : "2015-08-23T00:01:30",
"end_date" : "2015-08-23T14:02:30",
"duration" : 1
}'
curl -XPUT 'http://localhost:9200/test3/test/3' -d '{
"start_date" : "2015-08-23T00:01:45",
"end_date" : "2015-08-23T14:02:45",
"duration" : 1
}'
curl -XPUT 'http://localhost:9200/test3/test/4' -d '{
"start_date" : "2015-08-23T00:01:55",
"end_date" : "2015-08-23T14:02:55",
"duration" : 1
}'
curl -XPUT 'http://localhost:9200/test3/test/5' -d '{
"start_date" : "2015-08-23T00:02:00",
"end_date" : "2015-08-23T14:04:00",
"duration" : 1
}'
Script:
{
"interval":"minute",
"script": "start = doc['start_date'].value; duration = doc['duration'].value*1000*1000; l = []; for (long i = 0; i < duration; i += 60000) { l.add(start + i); }; return l;",
"field": null,
"lang": "groovy"
}