# Ingesting Geospatial data with Logstash

**URL:** https://discuss.elastic.co/t/ingesting-geospatial-data-with-logstash/27154
**Category:** Logstash
**Created:** [August 10, 2015, 8:41pm UTC](https://discuss.elastic.co/t/ingesting-geospatial-data-with-logstash/27154 "2015-08-10T20:41:02Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Freddie](https://avatars.discourse-cdn.com/v4/letter/f/a87d85/32.png) [@Freddie](https://discuss.elastic.co/u/Freddie)
#### Post date: [August 10, 2015, 8:41pm UTC](https://discuss.elastic.co/t/ingesting-geospatial-data-with-logstash/27154/1 "2015-08-10T20:41:02Z")

</div>

# Basic logstash conf ...

input {  
jdbc {  
jdbc\_driver\_library =\> "services/ows/webapps/ows/WEB-INF/lib/postgresql-8.4-701.jdbc3.jar"  
jdbc\_driver\_class =\> "org.postgresql.Driver"  
jdbc\_connection\_string =\> "jdbc:postgresql://localhost:5432/testdb"  
jdbc\_user =\> "justme"  
jdbc\_password =\> "password"  
statement =\> "select \* from vw\_test"  
}  
}

filter {  
mutate { add\_field =\> { "[@metadata][\_index]" =\> "gmti\_y2008-12\_v1" } }  
mutate { add\_field =\> { "[@metadata][\_type]" =\> "testidx" } }  
mutate { remove\_field =\> ["@version"] remove\_field =\> ["@timestamp"] }  
}

output {

# We build the "new" elasticsearch index in the default cluster

elasticsearch {  
cluster =\> "testdb"  
document\_type =\> "%{[@metadata][\_type]}"  
host =\> "localhost"  
index =\> "%{[@metadata][\_index]}"  
manage\_template =\> "true"  
port =\> "9200"  
protocol =\> "http"  
template =\> "/usr/share/logstash-1.5.2/lib/logstash/outputs/elasticsearch/elasticsearch-template.json"  
template\_name =\> "testing"  
template\_overwrite =\> "true"  
workers =\> "1"  
}

file {  
codec =\> "json"  
path =\> "/tmp/debug-filters.json"  
}  
}

# Basic mapping ...

"boundingArea": {  
"type": "geo\_shape",  
"tree": "quadtree",  
"precision": "1m"  
},

# for the geometry column "boundingArea" in postgresql, this GeoJson formatted syntax is built and defined as a string.

Sent from postgres: {"type":"Polygon","coordinates":[[[1.43875665801537,2.98127437512814],[1.43895665801537,2.98127437512814],  
[1.43895665801537,2.98147437512814],[1.43875665801537,2.98147437512814],[1.43875665801537,2.98127437512814]]]}::text

# but elasticsearch transforms into this:

"boundingArea":"{"type":"Polygon","coordinates":[[[1.43875665801537,2.98127437512814],[1.43895665801537,2.98127437512814],  
[1.43895665801537,2.98147437512814],[1.43875665801537,2.98147437512814],[1.43875665801537,2.98127437512814]]]}"

# and this syntax fails

Caused by: org.elasticsearch.index.mapper.MapperParsingException: failed to parse [boundingArea]  
at org.elasticsearch.index.mapper.geo.GeoShapeFieldMapper.parse(GeoShapeFieldMapper.java:263)  
at org.elasticsearch.index.mapper.object.ObjectMapper.serializeValue(ObjectMapper.java:706)  
at org.elasticsearch.index.mapper.object.ObjectMapper.parse(ObjectMapper.java:497)  
at org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:544)  
at org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:493)  
at org.elasticsearch.index.shard.IndexShard.prepareCreate(IndexShard.java:466)

"Shape must be an object consisting of type and coordinates"

# The coordinates interpreted as a sting, encapsulated in double quotes, spawning the escape clauses is the problem.

Does anyone know how I can get this to work?

thanks

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [August 11, 2015, 12:05am UTC](https://discuss.elastic.co/t/ingesting-geospatial-data-with-logstash/27154/2 "2015-08-11T00:05:06Z")

</div>

This appears to be a continuation of [Correct method for geospatial mapping from postgres -\> logstash -\> Elasticsearch](https://discuss.elastic.co/t/correct-method-for-geospatial-mapping-from-postgres-logstash-elasticsearch/27010), it'll be easier if you keep it to one thread 🙂

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [August 11, 2015, 12:05am UTC](https://discuss.elastic.co/t/ingesting-geospatial-data-with-logstash/27154/3 "2015-08-11T00:05:10Z")

</div>


