# Index Creation Using Nest(C#)

**URL:** <https://discuss.elastic.co/t/index-creation-using-nest-c/28099>\
**Category:** Elasticsearch\
**Created:** [August 26, 2015, 11:57am UTC](https://discuss.elastic.co/t/index-creation-using-nest-c/28099 "2015-08-26T11:57:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pavang6](https://avatars.discourse-cdn.com/v4/letter/p/a6a055/32.png) [@pavang6](https://discuss.elastic.co/u/pavang6)\
**Post date:** [August 26, 2015, 11:57am UTC](https://discuss.elastic.co/t/index-creation-using-nest-c/28099/1 "2015-08-26T11:57:59Z")

</div>

We are Using Nest client in our application . We are trying to modify the code below so that the geo point field count is dynamic not predefined like this.

elasticClient.CreateIndex(inputParameter.IndexName, s =\> s.NumberOfReplicas(inputParameter.ReplicaCount).NumberOfShards(inputParameter.ShardCount).AddMapping(m =\> m  
.MapFromAttributes()  
.Properties(p =\> p  
.GeoPoint(g =\> g.Name("OriginCoordinate").IndexLatLon())  
.GeoPoint(g =\> g.Name("DestinationCoordinate").IndexLatLon())).IndexAnalyzer(inputParameter.IndexAnalyzer)));

We would want to avoid mentioning geo point fields inline, we tried using PropertiesDescriptor to construct the geo point expression dynamically but could not succeed . Not sure what is going wrong .

Thanks,  
Pavan

---

<div class="post-metadata">

**Author:** ![Martijn\_Laarman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/martijn_laarman/32/4410_2.png) [@Martijn\_Laarman](https://discuss.elastic.co/u/Martijn_Laarman)\
**Post date:** [August 26, 2015, 12:05pm UTC](https://discuss.elastic.co/t/index-creation-using-nest-c/28099/2 "2015-08-26T12:05:41Z")

</div>

Can you explain what you mean with `geopoint field count` being dynamic and not predefined?

Do you have a dynamic list of geo point fields that you need to map as geopoints ?

```auto
.Properties(p=> { 
    foreach(var field in geoPoints) p.GeoPoint(g=>g.Name(field).IndexLatLon());
})

```

---

<div class="post-metadata">

**Author:** ![pavang6](https://avatars.discourse-cdn.com/v4/letter/p/a6a055/32.png) [@pavang6](https://discuss.elastic.co/u/pavang6)\
**Post date:** [August 28, 2015, 6:51am UTC](https://discuss.elastic.co/t/index-creation-using-nest-c/28099/3 "2015-08-28T06:51:25Z")

</div>

Hi , Thanks for the reply  
Yes i do have dynamic list of geo point fields.

.Properties(p=\> {  
foreach(var field in geoPoints) p.GeoPoint(g=\>g.Name(field).IndexLatLon());  
})

I tried above one but i am getting the following error.

'Not all code paths return a value in lambda expression of type'.

Thanks,

 ![](https://us1.discourse-cdn.com/elastic/original/2X/d/dadb90e5ce204c4457d0b3346612b695e725e1fd.PNG)

Thanks,  
Pavan

---

<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:** [July 5, 2017, 11:53pm UTC](https://discuss.elastic.co/t/index-creation-using-nest-c/28099/4 "2017-07-05T23:53:21Z")

</div>


