# Create Index with GeoPoint type

**URL:** https://discuss.elastic.co/t/create-index-with-geopoint-type/107293
**Category:** Elasticsearch
**Created:** [November 12, 2017, 8:18am UTC](https://discuss.elastic.co/t/create-index-with-geopoint-type/107293 "2017-11-12T08:18:50Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)
#### Post date: [November 14, 2017, 11:45pm UTC](https://discuss.elastic.co/t/create-index-with-geopoint-type/107293/4 "2017-11-14T23:45:20Z")

</div>

You'll need to delete the existing index if there is one and create again

```auto
public class Message
{
    public GeoLocation Location { get; set; }
}

var defaultIndex = "messages";
var client = new ElasticClient();

if (client.IndexExists(defaultIndex).Exists)
{		
    client.DeleteIndex(defaultIndex);
}
	
client.CreateIndex(defaultIndex, c=> c
    .Mappings(m => m
        .Map<Message>(mm => mm
            .AutoMap()
        )
    )
);

```

yields

```json
PUT http://localhost:9200/messages
{
  "mappings": {
    "message": {
      "properties": {
        "location": {
          "type": "geo_point"
        }
      }
    }
  }
}

```

---

_[View the full topic](https://discuss.elastic.co/t/create-index-with-geopoint-type/107293)._
