# Geo-point fields in nested mappings not accessible in Maps

**URL:** <https://discuss.elastic.co/t/geo-point-fields-in-nested-mappings-not-accessible-in-maps/249151>\
**Category:** Kibana\
**Tags:** maps\
**Created:** [September 18, 2020, 6:04pm UTC](https://discuss.elastic.co/t/geo-point-fields-in-nested-mappings-not-accessible-in-maps/249151 "2020-09-18T18:04:20Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![bgiordano](https://avatars.discourse-cdn.com/v4/letter/b/ba8739/32.png) [@bgiordano](https://discuss.elastic.co/u/bgiordano)\
**Post date:** [September 18, 2020, 6:04pm UTC](https://discuss.elastic.co/t/geo-point-fields-in-nested-mappings-not-accessible-in-maps/249151/1 "2020-09-18T18:04:20Z")

</div>

My index has a nested definition that includes a property of type geo-point. I can see it in Discover but it is not accessible from Documents layer in Maps. Is this the expected behavior or does my mapping need to change? I am using ES 7.6 currently.

example from mapping:

```auto
{
    "activityLocation": {
        "type": "nested",
        "properties": {
            "coordinates": {"type": "geo-point"},
            "name": {"type": "keyword"}
        }
    }
}

```

corresponding data in record:

```auto
{
    "activityLocation": {
        "coordinates": {"lat": 34.76544, "lon": -45.8888"},
        "name": "A Place"
    }
}

```

If I have the fields mapped separated - not as part of nested definition, then I can access the geo-point field in Maps. This is fine for an object that has a single entry - I can flatten.

Problem is when I have a field that is a list of objects, which is why I am treating as nested object so that I can retain relationships within each object.

```auto
{ 
    "activityLocation.coordinates": {"type": "geo-point"},
    "activityLocation.name": {"type": keyword"}
}

```

I know also, that for the "list of objects", I can populate a separate field to capture all the geo-points - just trying to avoid that, if possible. It is an accessible property in Maps.

```auto
{
    "activityLocationGeo.coordinates": {"type": "geo_point"},
    "activityLocation": {
        "type": "nested",
        "properties": {
            "coordinates": {"type": "geo-point"},
            "name": {"type": "keyword"}
        }
    }
}

```

Any other suggestions? Thank you.

---

<div class="post-metadata">

**Author:** ![Nathan\_Reese](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathan_reese/32/84829_2.png) [@Nathan\_Reese](https://discuss.elastic.co/u/Nathan_Reese)\
**Post date:** [September 19, 2020, 12:14pm UTC](https://discuss.elastic.co/t/geo-point-fields-in-nested-mappings-not-accessible-in-maps/249151/2 "2020-09-19T12:14:40Z")

</div>

Limited nested fields support was added to Kibana in [7.6](https://github.com/elastic/kibana/issues/1084#issuecomment-585178079) with the following features

- Index Patterns will detect Nested Fields correctly
- You will be able to watch Nested Fields in Discover
- Filtering on Nested Fields via the filter bar works
- KQL allows searching for nested fields (see the [KQL documentation]

Maps does not support nested geo\_point fields. There is an open issue, [https://github.com/elastic/kibana/issues/35135](https://github.com/elastic/kibana/issues/35135). Would you mind commenting on the issue with your use case?

---

<div class="post-metadata">

**Author:** ![bgiordano](https://avatars.discourse-cdn.com/v4/letter/b/ba8739/32.png) [@bgiordano](https://discuss.elastic.co/u/bgiordano)\
**Post date:** [September 19, 2020, 3:02pm UTC](https://discuss.elastic.co/t/geo-point-fields-in-nested-mappings-not-accessible-in-maps/249151/3 "2020-09-19T15:02:23Z")

</div>

I will comment as suggested. Thank you for clarifying for me.

---

<div class="post-metadata">

**Author:** ![bgiordano](https://avatars.discourse-cdn.com/v4/letter/b/ba8739/32.png) [@bgiordano](https://discuss.elastic.co/u/bgiordano)\
**Post date:** [September 28, 2020, 5:34pm UTC](https://discuss.elastic.co/t/geo-point-fields-in-nested-mappings-not-accessible-in-maps/249151/4 "2020-09-28T17:34:46Z")

</div>

Can I get some support for writing an ingest pipeline that will walk the array of nested objects an pull out the "coordinates" field into a separate field in the index that Maps can use?  
I can provide details.

I tried using an ingest pipeline with a "foreach" to walk the list and then an "append" within the "foreach" to copy each "coordinates" object to a new field (a list of "coordinates") for the index BUT "coordinates" is getting converted to a string and lat/long are no longer recognized as a "geo\_point". think I I understand why that is happening in the append processor.

Can you suggest a better way to access the "coordinates" objects from the nested list?

Mapping:

```auto
{ 
    "mappings": {
        "properties": {
            "nationsTravelled": {
                "type": "nested",
                "properties": {
                    "coordinates": {"type": "geo_point"},
                    "name": {"type": "keyword"}
                }
            },
           "nationsTravelledCoordsList": {"type":"geo_point"}
       }
}

```

Ingest pipeline piece:

```auto
{
     "foreach": {
         "field": "nationsTravelled",
         "processor": {
             "append": {
                 "field": "nationsTravelledCoordList",
                  "value": ["{{_ingest._value.coordinates}}"]
             }
         }
     }
}

```

---

<div class="post-metadata">

**Author:** ![jsanz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jsanz/32/53734_2.png) [@jsanz](https://discuss.elastic.co/u/jsanz)\
**Post date:** [September 29, 2020, 10:51am UTC](https://discuss.elastic.co/t/geo-point-fields-in-nested-mappings-not-accessible-in-maps/249151/5 "2020-09-29T10:51:21Z")

</div>

Hi @bgiordano,

I'd suggest you post your last question as a new topic, this time in the `Elastic Stack -> Elasticsearch` forum using the [`stack-ingest-management`](https://discuss.elastic.co/tags/c/elastic-stack/elasticsearch/6/stack-ingest-management) tag so you reach the correct audience for your issue.

---

<div class="post-metadata">

**Author:** ![jsanz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jsanz/32/53734_2.png) [@jsanz](https://discuss.elastic.co/u/jsanz)\
**Post date:** [September 29, 2020, 11:32am UTC](https://discuss.elastic.co/t/geo-point-fields-in-nested-mappings-not-accessible-in-maps/249151/6 "2020-09-29T11:32:33Z")

</div>

Nevermind, I think I got it. Instead of a `foreach` processor I used a painless script. You have below the full set of instructions from the dev console but the main part is the script itself that simply loops over the nested field and adds the coordinates to a new array that is later assigned to the `nationsTravelledCoordsList` field.

Mind that this probably would benefit from some type checking.

```auto
       int records = ctx.nationsTravelled.length;
       List result = []; 
       for (int i = 0; i < records; i++){
         result.add(ctx.nationsTravelled[i].coordinates)
       }
       ctx.nationsTravelledCoordsList = result ;

```

Let us know if this was helpful.

> **Script on DevTools**
>
> ```auto
> # Remove the index if it exists
> DELETE test_index_nested
> 
> # Create the index with the nested field and the outer list to receive the data
> PUT test_index_nested
> { 
> "mappings": {
> "properties": {
> "nationsTravelled": {
> "type": "nested",
> "properties": {
> "coordinates": {"type": "geo_point"},
> "name": {"type": "keyword"}
> }
> },
> "nationsTravelledCoordsList": {"type":"geo_point"}
> }
> }
> }
> 
> # Create a pipeline with a script processor
> PUT _ingest/pipeline/nested_test
> {
> "processors": [
> {
> "script": {
> "source": """
> int records = ctx.nationsTravelled.length;
> List result = []; 
> for (int i = 0; i < records; i++){
> result.add(ctx.nationsTravelled[i].coordinates)
> }
> ctx.nationsTravelledCoordsList = result ;
> """
> }
> }
> ]
> }
> 
> # Test the pipeline, mind that in string notation the order is lat/lon (!)
> POST _ingest/pipeline/nested_test/_simulate
> {
> "docs": [
> {
> "_index": "index",
> "_id": "id",
> "_source": {
> "nationsTravelled": [
> {
> "coordinates": "40.797177,-73.960648",
> "name": "New York"
> },
> {
> "coordinates": "19.425154,-99.113159",
> "name": "Mexico City"
> },
> {
> "coordinates": "-33.449777,-70.648956",
> "name": "Santiago de Chile"
> },
> {
> "coordinates": "-33.961586,18.462524",
> "name": "Cape Town"
> }
> ]
> }
> }
> ]
> }
> 
> # Insert the document
> POST test_index_nested/_doc?pipeline=nested_test
> {
> "nationsTravelled": [
> {
> "coordinates": "40.797177,-73.960648",
> "name": "New York"
> },
> {
> "coordinates": "19.425154,-99.113159",
> "name": "Mexico City"
> },
> {
> "coordinates": "-33.449777,-70.648956",
> "name": "Santiago de Chile"
> },
> {
> "coordinates": "-33.961586,18.462524",
> "name": "Cape Town"
> }
> ]
> }
> 
> # Check the result
> GET test_index_nested/_search
> 
> ```

---

<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:** [October 27, 2020, 11:32am UTC](https://discuss.elastic.co/t/geo-point-fields-in-nested-mappings-not-accessible-in-maps/249151/7 "2020-10-27T11:32:34Z")

</div>

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