# Need to mock elastic search Nest object

**URL:** <https://discuss.elastic.co/t/need-to-mock-elastic-search-nest-object/153809>\
**Category:** Elasticsearch\
**Created:** [October 24, 2018, 1:17pm UTC](https://discuss.elastic.co/t/need-to-mock-elastic-search-nest-object/153809 "2018-10-24T13:17:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![piyush\_kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/piyush_kumar/32/51705_2.png) [@piyush\_kumar](https://discuss.elastic.co/u/piyush_kumar)\
**Post date:** [October 24, 2018, 1:17pm UTC](https://discuss.elastic.co/t/need-to-mock-elastic-search-nest-object/153809/1 "2018-10-24T13:17:40Z")

</div>

var obj = service.Search(new student().Query());  
var Name= obj.Aggs.Terms("Name");

I did quick watch in vs2017 and try to create the Nest library object but getting error while assigning the value to Aggregate property .

new Nest.KeyedBucket  
{  
Key="XYZ school",  
KeyAsString=null,  
Aggregations=new Dictionary\<string, IAggregationContainer\>{}  
}  
Aggregations is protected internal property which not allowing me to assign value to it..

---

<div class="post-metadata">

**Author:** ![xavierfacq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xavierfacq/32/8744_2.png) [@xavierfacq](https://discuss.elastic.co/u/xavierfacq)\
**Post date:** [October 24, 2018, 1:43pm UTC](https://discuss.elastic.co/t/need-to-mock-elastic-search-nest-object/153809/2 "2018-10-24T13:43:59Z")

</div>

Hi,

Please:  
1°/ Expose your problem  
2°/ Format your code  
3°/ Give your versions  
4°/ Say "hi", "thanks" and "bye"

bye,  
Xavier

---

<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 21, 2018, 1:44pm UTC](https://discuss.elastic.co/t/need-to-mock-elastic-search-nest-object/153809/3 "2018-11-21T13:44:02Z")

</div>

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