title: ES NEST - How to Create an index and Bulk index dynamic objects with geometry (geo_point or geo_shape)?
body: <p>I have a Dataset for which I don't know or have the type in advance, nor the number of properties or their type.</p>
  <p>On execution, I obtain for that Dataset a DatasetSchema that contain the names, types and some flags for the properties.</p>
  <p>For geometry properties I have their GeoJson representation stored as string and I have some flags (isGeoShape, isGeoPoint) that tell the ES property type.</p>
  <p>I'm also using <a href="https://github.com/NetTopologySuite/NetTopologySuite" rel="nofollow noreferrer">NetTopologySuite</a> 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.</p>
  <pre><code>class DatasetSchema {
      List&lt;DatasetField&gt; Fields;
  }
  
  class DatasetField { 
      string Name;
      Type DataType;
      bool isGeoShape;
      bool isGeoPoint;
  }
  </code></pre>
  <p>Questions:</p>
  <ol>
  <li><p>How can I create such an ES index with unknown / dynamic mappings schema with NEST high level client with those geometry properties?</p>
  </li>
  <li><p>How can I Bulk index those documents with NEST high level client with Bulk or <a href="https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/indexing-documents.html#_advanced_bulk_indexing" rel="nofollow noreferrer">BulkAll</a> APIs with those geometry properties?</p>
  </li>
  </ol>
  <p>I saw <a href="https://stackoverflow.com/questions/51823724/index-dynamic-objects-with-elasticsearch-nest-stackoverflow-exception">here</a> and <a href="https://stackoverflow.com/questions/26744742/index-a-dynamic-object-using-nest">here</a>  that the bulk indexing might be done with BulkDescriptor:</p>
  <pre><code>dynamic obj = new System.Dynamic.ExpandoObject();
      // ….
  var descriptor = new BulkDescriptor();
  foreach (var doc in values)
  {
      descriptor.Index&lt;object&gt;(i =&gt; i
          .Index(&quot;abc&quot;)
          .Id((Id)doc.Id)
          .Document((object)doc));
  }
  client.Bulk(descriptor);
  </code></pre>
  <p>Still, I’m curious how geometry types should be treated?</p>
  <p>Thank you very much!
  Any thoughts or suggestions are welcomed!</p>