i am trying to save list of maps contents to elastic search(as nested type)and it is failing. sample code is below import ( "fmt" )
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]