# Failed to save list of maps content to elasticsearch

**URL:** <https://discuss.elastic.co/t/failed-to-save-list-of-maps-content-to-elasticsearch/121709>\
**Category:** Elasticsearch\
**Created:** [February 27, 2018, 5:39pm UTC](https://discuss.elastic.co/t/failed-to-save-list-of-maps-content-to-elasticsearch/121709 "2018-02-27T17:39:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kish](https://avatars.discourse-cdn.com/v4/letter/k/71e660/32.png) [@kish](https://discuss.elastic.co/u/kish)\
**Post date:** [February 27, 2018, 5:39pm UTC](https://discuss.elastic.co/t/failed-to-save-list-of-maps-content-to-elasticsearch/121709/1 "2018-02-27T17:39:02Z")

</div>

i am trying to save list of maps contents to Elasticsearch(as nested type)and it is failing. sample code is below  
package main

import (  
"fmt"  
)

const RegisterIndex = "register"  
const KpiIndex = "kpi"

// Register & Kpi Index doc type  
const RegisterDocType = "register"  
const KpiDocType = "kpi"

const KpiMapping = ` { "mappings": { "kpi": { "properties": { "kpi": { "type": "nested" } } } } }`

func main() {  
fmt.Println("Hello, playground")  
var List\_CounterData interface{}  
List\_CounterData = map[string]interface{}{}  
err := saveKpi(List\_Counterdata)  
if err != nil {  
fmt.Println("error in save")  
}   
}

func saveKpi(kpi interface{}) error {  
put1, err := elasticSearchClient.Index().  
Index(KpiIndex).  
Type(KpiDocType).  
Id("1001").  
BodyJson(kpi).  
Do(elasticSearchContext)  
if err != nil {  
fmt.Println("Failed to store Kpi , %v", err.Error())  
return err  
}  
fmt.Println("Indexed %s to index %s, type %s\n", put1.Id, put1.Index, put1.Type)  
return err  
}

My List\_Counterdata sample is below

> List\_Counterdata = [map[name: kisha] map[name: kish age: 29]]

When trying to create index, following the error

> elastic: Error 400 (Bad Request): failed to parse [type=mapper\_parsing\_exception]

---

<div class="post-metadata">

**Author:** ![kish](https://avatars.discourse-cdn.com/v4/letter/k/71e660/32.png) [@kish](https://discuss.elastic.co/u/kish)\
**Post date:** [February 28, 2018, 5:23am UTC](https://discuss.elastic.co/t/failed-to-save-list-of-maps-content-to-elasticsearch/121709/2 "2018-02-28T05:23:27Z")

</div>

any clue?

---

<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:** [March 28, 2018, 5:23am UTC](https://discuss.elastic.co/t/failed-to-save-list-of-maps-content-to-elasticsearch/121709/3 "2018-03-28T05:23:38Z")

</div>

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