# Geo\_shape - geo link problems with coordinates

**URL:** https://discuss.elastic.co/t/geo-shape-geo-link-problems-with-coordinates/179924
**Category:** Logstash
**Created:** [May 7, 2019, 8:57am UTC](https://discuss.elastic.co/t/geo-shape-geo-link-problems-with-coordinates/179924 "2019-05-07T08:57:56Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![gofbor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gofbor/32/46467_2.png) [@gofbor](https://discuss.elastic.co/u/gofbor)
#### Post date: [May 7, 2019, 8:57am UTC](https://discuss.elastic.co/t/geo-shape-geo-link-problems-with-coordinates/179924/1 "2019-05-07T08:57:56Z")

</div>

Hi,

I've got index with geo\_shape type field.  
I can POST doc via dev\_tool:

For example:  
POST test/doc  
{  
"geo\_link" : {  
"type": "LineString",  
"coordinates": [  
[  
-87.623177,  
41.881832  
],  
[  
-86.623177,  
42.881832  
]  
]  
}  
}

But when I try to post records via logstash I've got error: "geo coordinates must be numbers".

Logstash file:  
input {...}  
filter {  
mutate {  
add\_field =\> ["[geo\_link][type]", "linestring" ]  
add\_field =\> ["[geo\_link][coordinates]",[[-87.623177, 41.881832], [-86.623177, 42.881832]] ]  
}  
}  
output {...}

I tried many combinations of coordination number but I always have the same error.

---

<div class="post-metadata">

### Author: ![Filippo\_Pisapia](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/filippo_pisapia/32/51909_2.png) [@Filippo\_Pisapia](https://discuss.elastic.co/u/Filippo_Pisapia)
#### Post date: [May 7, 2019, 10:13am UTC](https://discuss.elastic.co/t/geo-shape-geo-link-problems-with-coordinates/179924/2 "2019-05-07T10:13:55Z")

</div>

I have the same problem , how to do indexing correctly a linestring via logstash?

---

<div class="post-metadata">

### Author: ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)
#### Post date: [May 7, 2019, 1:35pm UTC](https://discuss.elastic.co/t/geo-shape-geo-link-problems-with-coordinates/179924/3 "2019-05-07T13:35:31Z")

</div>

> [@gofbor](#):
>
> add\_field =\> ["[geo\_link][coordinates]",[[-87.623177, 41.881832], [-86.623177, 42.881832]] ]

That results in

```
  "geo_link" => {
           "type" => "linestring",
    "coordinates" => [
        [0] "[-87.623177, 41.881832]",
        [1] "[-86.623177, 42.881832]"
    ]
},

```

for me. You can split it up

```
        add_field => {
            "[geo_link][type]" => "linestring"
            "[geo_link][coordinates][0]" => [-87.623177, 41.881832]
            "[geo_link][coordinates][1]" => [-87.623177, 41.881833]
        }
    }

```

which results in

```
  "geo_link" => {
           "type" => "linestring",
    "coordinates" => {
        "1" => [
            [0] "-87.623177",
            [1] "41.881833"
        ],
        "0" => [
            [0] "-87.623177",
            [1] "41.881832"
        ]
    }
},

```

Note that these coordinates are all strings, not numbers. You may need to mutate+convert them.

---

<div class="post-metadata">

### Author: ![gofbor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gofbor/32/46467_2.png) [@gofbor](https://discuss.elastic.co/u/gofbor)
#### Post date: [May 8, 2019, 9:10am UTC](https://discuss.elastic.co/t/geo-shape-geo-link-problems-with-coordinates/179924/4 "2019-05-08T09:10:16Z")

</div>

Thanks for reply.  
But now I have message: "coordinates cannot be specified as objects"

I tried:  
{  
add\_field =\> ["[geo\_link][type]", "linestring" ]  
add\_field =\> ["[geo\_link][coordinates][0]", "[-87.623177, 41.881832]" ]  
add\_field =\> ["[geo\_link][coordinates][1]", "[-87.623177, 41.881832]" ]

```
    convert => { "[geo_link][coordinates][0]" => "float" }
    convert => { "[geo_link][coordinates][1]" => "float" }

```

}

I also tried:  
add\_field =\> ["[geo\_link][type]", "linestring" ]  
add\_field =\> ["[geo\_link][coordinates][0][lat]", " -87.623177" ]  
add\_field =\> ["[geo\_link][coordinates][0][lon]", "41.881832" ]  
add\_field =\> ["[geo\_link][coordinates][1][lat]", " -87.623177" ]  
add\_field =\> ["[geo\_link][coordinates][1][lon]", "41.881832" ]

but the same result.

---

<div class="post-metadata">

### Author: ![Filippo\_Pisapia](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/filippo_pisapia/32/51909_2.png) [@Filippo\_Pisapia](https://discuss.elastic.co/u/Filippo_Pisapia)
#### Post date: [May 8, 2019, 11:02am UTC](https://discuss.elastic.co/t/geo-shape-geo-link-problems-with-coordinates/179924/5 "2019-05-08T11:02:43Z")

</div>

I also tried:  
add\_field =\> ["[geo\_link][type]", "linestring" ]  
add\_field =\> ["[geo\_link][coordinates][0][0]", " -87.623177" ]  
add\_field =\> ["[geo\_link][coordinates][0][1]", "41.881832" ]  
add\_field =\> ["[geo\_link][coordinates][1][0]", " -87.623177" ]  
add\_field =\> ["[geo\_link][coordinates][1][1]", "41.881832" ]

but the same result.

---

<div class="post-metadata">

### Author: ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)
#### Post date: [May 8, 2019, 12:45pm UTC](https://discuss.elastic.co/t/geo-shape-geo-link-problems-with-coordinates/179924/6 "2019-05-08T12:45:58Z")

</div>

I cannot see a way to create an array of arrays of floats using mutate. So use ruby

```
    mutate {
        add_field => {
            "[geo_link][type]" => "linestring"
        }
    }
    ruby {
        code => '
            event.set("[geo_link][coordinates]", [[-87.623171, 41.881832], [-87.623177, 41.881833]])
        '
    }

```

which results in

```
  "geo_link" => {
           "type" => "linestring",
    "coordinates" => [
        [0] [
            [0] -87.623171,
            [1] 41.881832
        ],
        [1] [
            [0] -87.623177,
            [1] 41.881833
        ]
    ]
},
```

---

<div class="post-metadata">

### Author: ![parosio](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/parosio/32/27367_2.png) [@parosio](https://discuss.elastic.co/u/parosio)
#### Post date: [May 8, 2019, 2:06pm UTC](https://discuss.elastic.co/t/geo-shape-geo-link-problems-with-coordinates/179924/7 "2019-05-08T14:06:12Z")

</div>

Thank you for sharing this workaround!

---

<div class="post-metadata">

### Author: ![gofbor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gofbor/32/46467_2.png) [@gofbor](https://discuss.elastic.co/u/gofbor)
#### Post date: [May 8, 2019, 2:16pm UTC](https://discuss.elastic.co/t/geo-shape-geo-link-problems-with-coordinates/179924/8 "2019-05-08T14:16:41Z")

</div>

Exactly ! Thanks a lot.

---

<div class="post-metadata">

### Author: ![Filippo\_Pisapia](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/filippo_pisapia/32/51909_2.png) [@Filippo\_Pisapia](https://discuss.elastic.co/u/Filippo_Pisapia)
#### Post date: [May 8, 2019, 2:35pm UTC](https://discuss.elastic.co/t/geo-shape-geo-link-problems-with-coordinates/179924/9 "2019-05-08T14:35:40Z")

</div>

Works perfectly !!  
Many thanks

---

<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: [June 5, 2019, 2:35pm UTC](https://discuss.elastic.co/t/geo-shape-geo-link-problems-with-coordinates/179924/10 "2019-06-05T14:35:49Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
