func initIndices(client *elastic.Client) error { exists, err := client.IndexExists(IndexGeoFences).Do() if err != nil { return err } if !exists { log.Info("Creating Index for GeoFences.") mapping := `{ "settings":{ "number_of_shards":1, "number_of_replicas":0 }, "mappings":{ "geofence":{ "properties":{ "name":{ "type":"string" }, "radius":{ "type":"double" }, "center":{ "type":"geo_point" }, "owner": { "type": "string" } } } } }` createIndex, err := client.CreateIndex(IndexGeoFences).BodyString(mapping).Do() if err != nil { return err } if !createIndex.Acknowledged { return errors.New("Could not create Index for GeoFences") } } return nil }