# Reindex fails with array mapped to geo\_point

**URL:** https://discuss.elastic.co/t/reindex-fails-with-array-mapped-to-geo-point/172853
**Category:** Elasticsearch
**Created:** [March 18, 2019, 7:09pm UTC](https://discuss.elastic.co/t/reindex-fails-with-array-mapped-to-geo-point/172853 "2019-03-18T19:09:06Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![getorca](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/getorca/32/42269_2.png) [@getorca](https://discuss.elastic.co/u/getorca)
#### Post date: [March 18, 2019, 7:09pm UTC](https://discuss.elastic.co/t/reindex-fails-with-array-mapped-to-geo-point/172853/1 "2019-03-18T19:09:06Z")

</div>

I'm attempting to reindex after changing the mapping of one field from type text to type geo\_point.

The existing data in the source index looks like (but the lat\_long mapping type = text):

```auto
        "location" : {
            "lat_long" : [
              "49.266498",
              "-122.998938"
            ],
```

how ever on the \_reindex api call I get the following failures:

```auto
      "cause": {
        "type": "mapper_parsing_exception",
        "reason": "failed to parse field [location.lat_long] of type [geo_point]",
        "caused_by": {
          "type": "parse_exception",
          "reason": "unsupported symbol [.] in geohash [49.228065]",
          "caused_by": {
            "type": "illegal_argument_exception",
            "reason": "unsupported symbol [.] in geohash [49.228065]"
          }
```

---

<div class="post-metadata">

### Author: ![Ignacio\_Vera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ignacio_vera/32/36674_2.png) [@Ignacio\_Vera](https://discuss.elastic.co/u/Ignacio_Vera)
#### Post date: [March 19, 2019, 10:44am UTC](https://discuss.elastic.co/t/reindex-fails-with-array-mapped-to-geo-point/172853/2 "2019-03-19T10:44:30Z")

</div>

You need to cast the text values to double, otherwise it thinks it is a geohash input and fails.

For example this works for me (My mapping is slightly different but it should be easy to modify it for your needs):

```auto
POST _reindex
{
  "source": {
    "index": "src"
  },
  "dest": {
    "index": "tgt"
  },
  "script": {
    "source": "ctx._source.my_point[0] = Double.parseDouble(ctx._source.my_point[0]); ctx._source.my_point[1] = Double.parseDouble(ctx._source.my_point[1]);",
    "lang": "painless"
  }
} 

```

---

<div class="post-metadata">

### Author: ![getorca](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/getorca/32/42269_2.png) [@getorca](https://discuss.elastic.co/u/getorca)
#### Post date: [March 19, 2019, 4:11pm UTC](https://discuss.elastic.co/t/reindex-fails-with-array-mapped-to-geo-point/172853/3 "2019-03-19T16:11:28Z")

</div>

Thanks, that makes sense, but I'm running into the following error:

```auto
{
  "error": {
    "root_cause": [
      {
        "type": "script_exception",
        "reason": "runtime error",
        "script_stack": [
          "ctx._source.location.lat_long[1] = Double.parseDouble(ctx._source.location.lat_long[0]);",
          " ^---- HERE"
        ],
        "script": "ctx._source.location.lat_long[0] = Double.parseDouble(ctx._source.location.lat_long[1]); ctx._source.location.lat_long[1] = Double.parseDouble(ctx._source.location.lat_long[0]);",
        "lang": "painless"
      }
    ],
    "type": "script_exception",
    "reason": "runtime error",
    "script_stack": [
      "ctx._source.location.lat_long[1] = Double.parseDouble(ctx._source.location.lat_long[0]);",
      " ^---- HERE"
    ],
    "script": "ctx._source.location.lat_long[0] = Double.parseDouble(ctx._source.location.lat_long[1]); ctx._source.location.lat_long[1] = Double.parseDouble(ctx._source.location.lat_long[0]);",
    "lang": "painless",
    "caused_by": {
      "type": "class_cast_exception",
      "reason": "Cannot cast java.lang.Double to java.lang.String"
    }
  },
  "status": 500
}
```

My Java isn't the greatest.

---

<div class="post-metadata">

### Author: ![Ignacio\_Vera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ignacio_vera/32/36674_2.png) [@Ignacio\_Vera](https://discuss.elastic.co/u/Ignacio_Vera)
#### Post date: [March 20, 2019, 5:47am UTC](https://discuss.elastic.co/t/reindex-fails-with-array-mapped-to-geo-point/172853/4 "2019-03-20T05:47:21Z")

</div>

Looks like you might have a mixture of Doubles and test in your original source. You might want to call toString() method before parsing it to Double. I added some extra checks in case you have missing values:

```auto
POST _reindex
{
  "source": {
    "index": "src"
  },
  "dest": {
    "index": "tgt"
  },
  "script": {
    "source": "if (ctx._source.my_point != null && ctx._source.my_point.length == 2) {ctx._source.my_point[0] = Double.parseDouble(ctx._source.my_point[0].toString()); ctx._source.my_point[1] = Double.parseDouble(ctx._source.my_point[1].toString());}",
    "lang": "painless"
  }
} 

```

---

<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: [April 17, 2019, 5:47am UTC](https://discuss.elastic.co/t/reindex-fails-with-array-mapped-to-geo-point/172853/5 "2019-04-17T05:47:28Z")

</div>

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