Field showing in Discover tab but not getting aggregated in Visualizations

This is the mapping i have defined for loglevel :

"loglevel" : {
"type" : "string",
"norms" : {
"enabled" : false
},
"fielddata" : {
"format" : "disabled"
},
"fields" : {
"raw" : {
"type" : "string",
"index" : "not_analyzed",
"ignore_above" : 256
}
}