# ES NEST - How to Create an index and Bulk index dynamic objects with geometry (geo\_point or geo\_shape)?

**URL:** <https://discuss.elastic.co/t/es-nest-how-to-create-an-index-and-bulk-index-dynamic-objects-with-geometry-geo-point-or-geo-shape/275608>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [June 10, 2021, 5:30pm UTC](https://discuss.elastic.co/t/es-nest-how-to-create-an-index-and-bulk-index-dynamic-objects-with-geometry-geo-point-or-geo-shape/275608 "2021-06-10T17:30:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Florin\_Virdol](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/florin_virdol/32/83376_2.png) [@Florin\_Virdol](https://discuss.elastic.co/u/Florin_Virdol)\
**Post date:** [June 10, 2021, 5:30pm UTC](https://discuss.elastic.co/t/es-nest-how-to-create-an-index-and-bulk-index-dynamic-objects-with-geometry-geo-point-or-geo-shape/275608/1 "2021-06-10T17:30:14Z")

</div>

Hi, guys!  
I have a Dataset for which I don't know or have the type in advance, nor the number of properties or their type.

On execution, I obtain for that Dataset a DatasetSchema that contain the names, types and some flags for the properties.

For geometry properties I have their GeoJson representation stored as string and I have some flags (isGeoShape, isGeoPoint) that tell the ES property type.

I'm also using [NetTopologySuite](https://github.com/NetTopologySuite/NetTopologySuite) if it's needed to parse those GeoJsons to actual Geometry objects, but i rather not do this extra parsing and use the GeoJson strings instead.

```auto
class DatasetSchema {
	List<DatasetField> Fields;
}

class DatasetField { 
	string Name;
	Type DataType;
	bool isGeoShape;
	bool isGeoPoint;
}

```

Q:

1. How can I create such an ES index with unknown / dynamic mappings schema with NEST high level client with those geometry properties?

2. How can I Bulk index those documents with NEST high level client with Bulk or BulkAll APIs with those geometry properties?

I saw [here](https://stackoverflow.com/questions/51823724/index-dynamic-objects-with-elasticsearch-nest-stackoverflow-exception) and [here](https://stackoverflow.com/questions/26744742/index-a-dynamic-object-using-nest) that the bulk indexing might be done with BulkDescriptor:

```auto
dynamic obj = new System.Dynamic.ExpandoObject();
	// ….
var descriptor = new BulkDescriptor();
foreach (var doc in values)
{
    descriptor.Index<object>(i => i
        .Index("abc")
        .Id((Id)doc.Id)
        .Document((object)doc));
}
client.Bulk(descriptor);

```

Still, I’m curious how geometry types should be treated?

Thank you very much!  
Any thoughts or suggestions are welcomed!

---

<div class="post-metadata">

**Author:** ![jsanz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jsanz/32/53734_2.png) [@jsanz](https://discuss.elastic.co/u/jsanz)\
**Post date:** [June 14, 2021, 8:59am UTC](https://discuss.elastic.co/t/es-nest-how-to-create-an-index-and-bulk-index-dynamic-objects-with-geometry-geo-point-or-geo-shape/275608/2 "2021-06-14T08:59:30Z")

</div>

> [@Florin\_Virdol](#):
>
> How can I create such an ES index with unknown / dynamic mappings schema with NEST high level client with those geometry properties?

Unfortunately, as you are experiencing, there is no automatic detection for geometric fields.

If you can't create the mapping in advance you could have a [dynamic template](https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic-templates.html) assuming the field name follows a pattern. So for example you could set a rule for any new field named `location` or `geometry` to be mapped automatically as a `geo_shape`.

Hope this helps!

---

<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 12, 2021, 8:59am UTC](https://discuss.elastic.co/t/es-nest-how-to-create-an-index-and-bulk-index-dynamic-objects-with-geometry-geo-point-or-geo-shape/275608/3 "2021-07-12T08:59:46Z")

</div>

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