# Pyspark Keeps Enforcing Type Text For Geo-Point, Despite Enforced Mapping

**URL:** <https://discuss.elastic.co/t/pyspark-keeps-enforcing-type-text-for-geo-point-despite-enforced-mapping/254246>\
**Category:** Elasticsearch\
**Tags:** es-hadoop\
**Created:** [November 4, 2020, 10:34am UTC](https://discuss.elastic.co/t/pyspark-keeps-enforcing-type-text-for-geo-point-despite-enforced-mapping/254246 "2020-11-04T10:34:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aneeqyusuf](https://avatars.discourse-cdn.com/v4/letter/a/f6c823/32.png) [@aneeqyusuf](https://discuss.elastic.co/u/aneeqyusuf)\
**Post date:** [November 4, 2020, 10:34am UTC](https://discuss.elastic.co/t/pyspark-keeps-enforcing-type-text-for-geo-point-despite-enforced-mapping/254246/1 "2020-11-04T10:34:21Z")

</div>

Hi guys,  
I have been trying to index some data, with a geo\_point value into Elasticsearch for a coordinate map visualization on Kibana, using Spark, mainly the es-hadoop connector. Both the connector and ELK versions are 7.9.3. And I have already referred to a similar problem referred on this forum earlier: [Elastic spark connector not able map longitude ,latitude values to geo\_type](https://discuss.elastic.co/t/elastic-spark-connector-not-able-map-longitude-latitude-values-to-geo-type/60865/6). Please note that my location value in spark is already a string, in the format "lat, long"  
Here is my mapping:

```auto
    {  
    "settings": {
            "index": {
                "number_of_shards": "1",
                "number_of_replicas": "1",
                    "analysis": {
                        "analyzer": {
                            "analyzer-name": {
                            "filter": "lowercase",
                            "type": "custom",
                            "tokenizer": "keyword"
                        }
                    }
                }
            }
        },
    "mappings": {
          "properties": {
            "booking_end_at": {
              "type": "date"
            },
            "booking_location": {
             "type": "geo_point"
            },
            "booking_start_at": {
              "type": "date"
            },
            "created_at": {
              "type": "date"
            },
            "updated_at": {
              "type": "date"
            }
          }
        }
    }

```

and the code I am using for indexing is here:

```auto
    df_bookings.write.format(
        "org.elasticsearch.spark.sql"
    ).option(
        "es.resource", '%s/%s' % ('bookings', 'docs')
    ).option(
        "es.nodes", 'localhost'
    ).option(
        "es.port", 9200
    ).option(
        "es.mapping.id", 'id'
    ).option(
        "es.nodes.discovery", "false"
    ).option(
        "es.nodes.wan.only", "true"
    ).option(
        "es.http.timeout", "10m"
    ).option(
        "es.write.operation", "index"
    ).mode("append"
    ).save()

```

Yet, I still get the following error from Pyspark:

```auto
org.elasticsearch.hadoop.rest.EsHadoopRemoteException: illegal_argument_exception: mapper [booking_location] cannot be changed from type [geo_point] to [text].

```

I am guessing the connector is enforcing the text data type, while the mapping has already imposed the geo\_point. How can I solve this? Thanks in advance.

---

<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:** [December 2, 2020, 10:34am UTC](https://discuss.elastic.co/t/pyspark-keeps-enforcing-type-text-for-geo-point-despite-enforced-mapping/254246/2 "2020-12-02T10:34:26Z")

</div>

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