Index Creation Using Nest(C#)

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

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 ?

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

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,

Thanks,
Pavan