Getting AggregationExecutionException:could not find the appropriate value context to perform aggregation [startd]];

I have data in this format
{
"_index": "resources",
"_type": "cresource",
"_id": "a1_6980",
"_score": 1.0,
"_source": {
"name": "a1_6980",
"region": "useast",
"costs": [{
"cost": 8.464E-4,
"endDate": "2017-02-14T00:00:00+00:00",
"startDate": "2017-02-13T00:00:00+00:00"
}, {
"cost": 7.65E-6,
"endDate": "2017-02-14T00:00:00+00:00",
"startDate": "2017-02-13T00:00:00+00:00"
}],
"id": 6,
"cId": 6980
}
}

when i try to get cost based on start time and end time ,I am getting "nested: AggregationExecutionException[could not find the appropriate value context to perform aggregation [startd]]"
{
"query": {
"bool": {
"must": [{
"match": {
"id": {
"query": 6,
"type": "phrase"
}
}
}, {
"match": {
"region": {
"query": "eastus",
"type": "phrase"
}
}
}, {
"match": {
"externalUUID": {
"query": "a1_6980",
"operator": "AND"
}
}
}, {
"nested": {
"query": {
"range": {
"costs.startDate": {
"from": "2017-02-13T00:00:00+00:00",
"to": null,
"include_lower": true,
"include_upper": true
}
}
},
"path": "costs"
}
}, {
"nested": {
"query": {
"range": {
"costs.endDate": {
"from": null,
"to": "2017-02-14T00:00:00+00:00",
"include_lower": true,
"include_upper": true
}
}
},
"path": "costs"
}
}]
}
},
"aggregations": {
"costagg": {
"nested": {
"path": "costs"
},
"aggregations": {
"startd": {
"date_range": {
"ranges": [{
"key": "startDate",
"from": "2017-02-13T00:00:00+00:00"
}, {
"key": "endDate",
"to": "2017-02-14T00:00:00+00:00"
}]
},
"aggregations": {
"TotalCost": {
"sum": {
"field": "cost"
}
}
}
}
}
}
}
}

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