# Indexing Multipolyon with Elasticearch

**URL:** <https://discuss.elastic.co/t/indexing-multipolyon-with-elasticearch/286265>\
**Category:** Elasticsearch\
**Created:** [October 8, 2021, 4:26pm UTC](https://discuss.elastic.co/t/indexing-multipolyon-with-elasticearch/286265 "2021-10-08T16:26:45Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Faradandy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/faradandy/32/95618_2.png) [@Faradandy](https://discuss.elastic.co/u/Faradandy)\
**Post date:** [October 8, 2021, 4:26pm UTC](https://discuss.elastic.co/t/indexing-multipolyon-with-elasticearch/286265/1 "2021-10-08T16:26:45Z")

</div>

Hi there,

I'm using Elasticsearch 7.15 with GDAL 3.3.1 and trying to index the UK Land Registry Dataset.

I currently have these data stored in a PSQL table and am trying to use ogr2ogr to create the ES index.

I've defined a mapping

```auto
"mappings" : {
        "_meta" : {
          "fid" : "ogc_fid"
        },
        "properties" : {
          "additional_proprietor_indicator" : {
            "type" : "text"
          },
          "address" : {
            "type" : "text"
          },
          "area" : {
            "type" : "double"
          },
          "change_indicator" : {
            "type" : "text"
          },
          "class_of_title" : {
            "type" : "text"
          },
          "company_registration_no_1" : {
            "type" : "text"
          },
          "company_registration_no_2" : {
            "type" : "text"
          },
          "company_registration_no_3" : {
            "type" : "text"
          },
          "company_registration_no_4" : {
            "type" : "text"
          },
          "country_incorporated_1" : {
            "type" : "text"
          },
          "country_incorporated_2" : {
            "type" : "text"
          },
          "country_incorporated_3" : {
            "type" : "text"
          },
          "country_incorporated_4" : {
            "type" : "text"
          },
          "county" : {
            "type" : "text"
          },
          "created_at" : {
            "type" : "text"
          },
          "date_proprietor_added" : {
            "type" : "text"
          },
          "district" : {
            "type" : "text"
          },
          "estate_interest" : {
            "type" : "text"
          },
          "multiple_address_indicator" : {
            "type" : "text"
          },
          "ogc_fid" : {
            "type" : "long"
          },
          "poly_id" : {
            "type" : "integer"
          },
          "polygons" : {
            "type" : "geo_shape"
          },
          "postcode" : {
            "type" : "text"
          },
          "price_paid" : {
            "type" : "text"
          },
          "proprietor_1_address_1" : {
            "type" : "text"
          },
          "proprietor_1_address_2" : {
            "type" : "text"
          },
          "proprietor_1_address_3" : {
            "type" : "text"
          },
          "proprietor_2_address_1" : {
            "type" : "text"
          },
          "proprietor_2_address_2" : {
            "type" : "text"
          },
          "proprietor_2_address_3" : {
            "type" : "text"
          },
          "proprietor_3_address_1" : {
            "type" : "text"
          },
          "proprietor_3_address_2" : {
            "type" : "text"
          },
          "proprietor_3_address_3" : {
            "type" : "text"
          },
          "proprietor_4_address_1" : {
            "type" : "text"
          },
          "proprietor_4_address_2" : {
            "type" : "text"
          },
          "proprietor_4_address_3" : {
            "type" : "text"
          },
          "proprietor_name_1" : {
            "type" : "text"
          },
          "proprietor_name_2" : {
            "type" : "text"
          },
          "proprietor_name_3" : {
            "type" : "text"
          },
          "proprietor_name_4" : {
            "type" : "text"
          },
          "proprietorship_category_1" : {
            "type" : "text"
          },
          "proprietorship_category_2" : {
            "type" : "text"
          },
          "proprietorship_category_3" : {
            "type" : "text"
          },
          "proprietorship_category_4" : {
            "type" : "text"
          },
          "recent_status" : {
            "type" : "text"
          },
          "region" : {
            "type" : "text"
          },
          "registered_status" : {
            "type" : "text"
          },
          "tenure" : {
            "type" : "text"
          },
          "title_number" : {
            "type" : "text"
          },
          "updated_at" : {
            "type" : "text"
          },
          "uprn" : {
            "type" : "text"
          }
        }

```

and am using the command

```auto
ogr2ogr -progress --config ES_OVERWRITE 1 -f "Elasticsearch" {ES_HOST} PG:"{DB_CONN_STR}" "{DB_TABLE}" -nln {INDEX_NAME}

```

but keep getting the error

```auto
{"index":{"_index":"core_landregistry","_type":"FeatureCollection","_id":"Fwx-YHwByMdODXOcCpWC","status":400,"error":{"type":"illegal_argument_exception","reason":"Invalid type: expecting [_doc] but got [FeatureCollection]"}}}

```

I'm not quite sure where to start to try to solve this... A colleague ran the same command with the same mapping and didn't get the error. We have identical versions of ES and GDAL installed and the database table we're indexing was created from the same SQL dump.

Has anyone experienced this error before?

---

<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:** [October 11, 2021, 12:25am UTC](https://discuss.elastic.co/t/indexing-multipolyon-with-elasticearch/286265/2 "2021-10-11T00:25:50Z")

</div>

Welcome to our community! 😃

I don't know what `ogr2ogr` is, but does it have an option to define the Elasticsearch [`_type`](https://www.elastic.co/guide/en/elasticsearch/reference/7.15/removal-of-types.html)? If it does then use `_doc`.

---

<div class="post-metadata">

**Author:** ![Faradandy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/faradandy/32/95618_2.png) [@Faradandy](https://discuss.elastic.co/u/Faradandy)\
**Post date:** [October 11, 2021, 8:34am UTC](https://discuss.elastic.co/t/indexing-multipolyon-with-elasticearch/286265/3 "2021-10-11T08:34:31Z")

</div>

Hi Mark,

ogr2ogr is a super powerful tool for converting geospatial data between different formats that comes packaged with GDAL, it does have a MAPPING\_TYPE option that I can use to define the type as a doc, will give that a go.

I am still confused about this solution though, I thought mapping types were removed in 7.15? My understanding was that the \_type field was deprecated in 6.0.0 so how would it make any difference? Am I missing something?

Thanks!  
Andy

---

<div class="post-metadata">

**Author:** ![nickpeihl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nickpeihl/32/112622_2.png) [@nickpeihl](https://discuss.elastic.co/u/nickpeihl)\
**Post date:** [October 11, 2021, 4:59pm UTC](https://discuss.elastic.co/t/indexing-multipolyon-with-elasticearch/286265/4 "2021-10-11T16:59:19Z")

</div>

Hi Andy,

I think you might want to add this flag

```auto
-lco MAPPING_NAME=doc

```

to your GDAL command.

There's more details about using GDAL with Elasticsearch in [this blog post](https://www.elastic.co/blog/how-to-ingest-geospatial-data-into-elasticsearch-with-gdal).

---

<div class="post-metadata">

**Author:** ![Faradandy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/faradandy/32/95618_2.png) [@Faradandy](https://discuss.elastic.co/u/Faradandy)\
**Post date:** [October 11, 2021, 5:31pm UTC](https://discuss.elastic.co/t/indexing-multipolyon-with-elasticearch/286265/5 "2021-10-11T17:31:34Z")

</div>

Hi Nick,

Yeah this is exactly the flag I was going to try (I don't have access today so will have to try tomorrow). I'm still confused about why it would work though, the blog post you've linked to says:

> The MAPPING\_NAME parameter has no effect on Elasticsearch 7 and later because [mapping types have been removed.](https://www.elastic.co/guide/en/elasticsearch/reference/7.4/removal-of-types.html)

and we're using Elasticsearch 7.15 so not sure why I'm even getting a mapping type error in the first place!

Andy

---

<div class="post-metadata">

**Author:** ![nickpeihl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nickpeihl/32/112622_2.png) [@nickpeihl](https://discuss.elastic.co/u/nickpeihl)\
**Post date:** [October 11, 2021, 5:50pm UTC](https://discuss.elastic.co/t/indexing-multipolyon-with-elasticearch/286265/6 "2021-10-11T17:50:56Z")

</div>

Perhaps something has changed in GDAL 3.2 or 3.3. I wrote that blog based on GDAL 3.1. It might be a regression that was missed. I don't believe GDAL runs functional tests against an actual Elasticsearch instance.

---

<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:** [November 8, 2021, 5:51pm UTC](https://discuss.elastic.co/t/indexing-multipolyon-with-elasticearch/286265/7 "2021-11-08T17:51:33Z")

</div>

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