Json containing all fields with default value

We want to create a json containing all the fields (with default values ) that exists in the index. We want to index this json doc into our production and refresh the index before actual data flows in. This was all the charts in the kibana will not throw "Could not locate that index-pattern-field" error. GetMapping does return the fields along with other information about the field. Is there any way to query and get only field names and create a json out of it in shorter time.

What is a "default value"?

I'm not sure but are you looking for the mapping?

assume that my index has 50 fields and i need to inject a json with all the 50 fields and the default value needs to be assigned based on the datatype for the field. If the field is string, it can contain empty string, if the field is int, default value can be 0, and so on..Now creating the json out of GetMappingApi is possible but it involves lot of manual work. Want to check is there any way we can reduce the manual work ?

If i run the GetMappingAPI i get the following

"source": {
"type": "text",
"norms": false,
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"tags": {
"type": "text",
"norms": false,
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"uri_query": {
"type": "text",
"norms": false,
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
what i need is
{
"source",
"tags",
"uri_query"
}

Actually the approach i used is wrong... I shouldn't inject the JSON with all the fields so that all fields are indexed. Instead should create the index with the mappings containing all the fields. Thanks David for the reply and to reply for your question made me to think and found the right way which is actually the standard way.

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