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

**URL:** https://discuss.elastic.co/t/getting-aggregationexecutionexception-could-not-find-the-appropriate-value-context-to-perform-aggregation-startd/103053
**Category:** Elasticsearch
**Created:** [October 6, 2017, 5:31pm UTC](https://discuss.elastic.co/t/getting-aggregationexecutionexception-could-not-find-the-appropriate-value-context-to-perform-aggregation-startd/103053 "2017-10-06T17:31:50Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![eswar](https://avatars.discourse-cdn.com/v4/letter/e/5f9b8f/32.png) [@eswar](https://discuss.elastic.co/u/eswar)
#### Post date: [October 6, 2017, 5:31pm UTC](https://discuss.elastic.co/t/getting-aggregationexecutionexception-could-not-find-the-appropriate-value-context-to-perform-aggregation-startd/103053/1 "2017-10-06T17:31:50Z")

</div>

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"  
}  
}  
}  
}  
}  
}  
}  
}

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [November 3, 2017, 5:31pm UTC](https://discuss.elastic.co/t/getting-aggregationexecutionexception-could-not-find-the-appropriate-value-context-to-perform-aggregation-startd/103053/2 "2017-11-03T17:31:51Z")

</div>

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