# Bulk Insert GeoJSON from Postgresql

**URL:** <https://discuss.elastic.co/t/bulk-insert-geojson-from-postgresql/5018>\
**Category:** Elasticsearch\
**Created:** [August 1, 2011, 6:01pm UTC](https://discuss.elastic.co/t/bulk-insert-geojson-from-postgresql/5018 "2011-08-01T18:01:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adam\_Estrada](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/adam_estrada/32/2704_2.png) [@Adam\_Estrada](https://discuss.elastic.co/u/Adam_Estrada)\
**Post date:** [August 1, 2011, 6:01pm UTC](https://discuss.elastic.co/t/bulk-insert-geojson-from-postgresql/5018/1 "2011-08-01T18:01:14Z")

</div>

All,

It's relatively simple to get spatial data from Postgres. The  
following example is geojson exported directly from Postgis.

[http://pastebin.com/25NsAteH](http://pastebin.com/25NsAteH)

What would I have to do to bulk load the data in to ES?

Thanks in advance,  
Adam

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [August 1, 2011, 8:59pm UTC](https://discuss.elastic.co/t/bulk-insert-geojson-from-postgresql/5018/2 "2011-08-01T20:59:27Z")

</div>

First, you will need to create an index, and have geo\_type mapping on at  
least the geometry.coordinates (see  
[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/geo-point-type.html)).

Then you will need to use your favorite lang to read the data from the  
database and index it into elasticsearch.

On Mon, Aug 1, 2011 at 9:01 PM, Adam Estrada [estrada.adam@gmail.com](mailto:estrada.adam@gmail.com) wrote:

> All,
> 
> It's relatively simple to get spatial data from Postgres. The  
> following example is geojson exported directly from Postgis.
> 
> [GeoJSON 2 ElasticSearch - Pastebin.com](http://pastebin.com/25NsAteH)
> 
> What would I have to do to bulk load the data in to ES?
> 
> Thanks in advance,  
> Adam

---

<div class="post-metadata">

**Author:** ![Adam\_Estrada](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/adam_estrada/32/2704_2.png) [@Adam\_Estrada](https://discuss.elastic.co/u/Adam_Estrada)\
**Post date:** [August 1, 2011, 9:03pm UTC](https://discuss.elastic.co/t/bulk-insert-geojson-from-postgresql/5018/3 "2011-08-01T21:03:15Z")

</div>

I literally have no idea how to get this in to ES. It's properly  
formatted GeoJSON from OGR2OGR. Any tips on bulk loading this would be  
great!

{  
"type":"FeatureCollection",  
"features":[{  
"type":"Feature",  
"properties":{  
"id":1376628261,  
"owner":"62311807@N05",  
"secret":"f9a4598e7d",  
"server":5109,  
"farm":6,  
"title":"Relax.",  
"accuracy":11,  
"place\_id":"\_cv6vY5WV7\_DBdU",  
"woeid":755126,  
"translated":"Relax ",  
"tags":"",  
"date\_taken":"2010/07/22",  
"url":"[Explore | Flickr](http://www.flickr.com/photos/)  
62311807@N05/5671595557/",  
"description":"",  
"photo\_url":"[http://farm6.static.flickr.com/](http://farm6.static.flickr.com/)  
5109/5671595557\_f9a4598e7d\_z.jpg",  
"date\_inserted":"2011/07/24"  
},  
"geometry":{  
"type":"Point",  
"coordinates":[-3.293151,  
36.940974  
]  
}  
}  
]  
}

On Aug 1, 2:01 pm, Adam Estrada [estrada.a...@gmail.com](mailto:estrada.a...@gmail.com) wrote:

> All,
> 
> It's relatively simple to getspatialdata from Postgres. The  
> following example is geojson exported directly from Postgis.
> 
> [GeoJSON 2 ElasticSearch - Pastebin.com](http://pastebin.com/25NsAteH)
> 
> What would I have to do to bulk load the data in to ES?
> 
> Thanks in advance,  
> Adam

---

<div class="post-metadata">

**Author:** ![Adam\_Estrada](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/adam_estrada/32/2704_2.png) [@Adam\_Estrada](https://discuss.elastic.co/u/Adam_Estrada)\
**Post date:** [August 1, 2011, 9:05pm UTC](https://discuss.elastic.co/t/bulk-insert-geojson-from-postgresql/5018/4 "2011-08-01T21:05:27Z")

</div>

Ahh,

Thanks Shay! I was hoping to use the bulk loader like Sophia did here.

> **['sproke](http://sproke.blogspot.com/)**
>
> Piqued filled solutions to minor irritations.

That would be perfect. Otherwise I suppose it would be easy enough to  
script this in to ES.

Adam

On Aug 1, 4:59 pm, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:

> First, you will need to create an index, and have geo\_type mapping on at  
> least the geometry.coordinates (seehttp://www.elasticsearch.org/guide/reference/mapping/geo-point-type.html).
> 
> Then you will need to use your favorite lang to read the data from the  
> database and index it into elasticsearch.
> 
> On Mon, Aug 1, 2011 at 9:01 PM, Adam Estrada [estrada.a...@gmail.com](mailto:estrada.a...@gmail.com) wrote:
> 
> > All,
> 
> > It's relatively simple to get spatial data from Postgres. The  
> > following example is geojson exported directly from Postgis.
> 
> > [GeoJSON 2 ElasticSearch - Pastebin.com](http://pastebin.com/25NsAteH)
> 
> > What would I have to do to bulk load the data in to ES?
> 
> > Thanks in advance,  
> > Adam

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [August 1, 2011, 9:05pm UTC](https://discuss.elastic.co/t/bulk-insert-geojson-from-postgresql/5018/5 "2011-08-01T21:05:56Z")

</div>

elasticsearch has a REST API and a built in Java API. If you want to use the  
REST API, then I suggest using one of the client libs listed here:  
[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/appendix/clients.html).

I suggest, if you want to get familiar with elasticsearch in a very high  
level, to go through the README on the github project and use curl to work  
with it: [GitHub - elastic/elasticsearch: Free and Open, Distributed, RESTful Search Engine](https://github.com/elasticsearch/elasticsearch).

On Tue, Aug 2, 2011 at 12:03 AM, Adam Estrada [estrada.adam@gmail.com](mailto:estrada.adam@gmail.com)wrote:

> I literally have no idea how to get this in to ES. It's properly  
> formatted GeoJSON from OGR2OGR. Any tips on bulk loading this would be  
> great!
> 
> {  
> "type":"FeatureCollection",  
> "features":[{  
> "type":"Feature",  
> "properties":{  
> "id":1376628261,  
> "owner":"62311807@N05",  
> "secret":"f9a4598e7d",  
> "server":5109,  
> "farm":6,  
> "title":"Relax.",  
> "accuracy":11,  
> "place\_id":"\_cv6vY5WV7\_DBdU",  
> "woeid":755126,  
> "translated":"Relax ",  
> "tags":"",  
> "date\_taken":"2010/07/22",  
> "url":"[Explore | Flickr](http://www.flickr.com/photos/)  
> 62311807@N05/5671595557/",  
> "description":"",  
> "photo\_url":"[http://farm6.static.flickr.com/](http://farm6.static.flickr.com/)  
> 5109/5671595557\_f9a4598e7d\_z.jpg",  
> "date\_inserted":"2011/07/24"  
> },  
> "geometry":{  
> "type":"Point",  
> "coordinates":[-3.293151,  
> 36.940974  
> ]  
> }  
> }  
> ]  
> }
> 
> On Aug 1, 2:01 pm, Adam Estrada [estrada.a...@gmail.com](mailto:estrada.a...@gmail.com) wrote:
> 
> > All,
> > 
> > It's relatively simple to getspatialdata from Postgres. The  
> > following example is geojson exported directly from Postgis.
> > 
> > [GeoJSON 2 ElasticSearch - Pastebin.com](http://pastebin.com/25NsAteH)
> > 
> > What would I have to do to bulk load the data in to ES?
> > 
> > Thanks in advance,  
> > Adam

---

<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 6, 2017, 3:58am UTC](https://discuss.elastic.co/t/bulk-insert-geojson-from-postgresql/5018/6 "2017-07-06T03:58:34Z")

</div>


