Script field not returning value

Hi support,
I've created this Script Field in Kibana index pattern, but I've an issue, nothing is return...
Each time I have a field name : category_name that match "Router", I should have a value (netflow value), But I always have null !

What I do wrong ?

Regards,
Philippe

double netflow = 15.22;
if (doc['category_name'].size() == 0) {
    return null;
} else { 
    if (doc['category_name'].value == 'Router') {
    return netflow;
    }
}

Can you share an example document and the mapping of your index?

@flash1293

You put your finger exactly on the good things !

"category_name": {
          "type": "keyword",
          "normalizer": "uppercase"
        },

I 've to put my value to "ROUTER" and not "Router" cause of the normalizer that we added. :wink:

Thanks a lot.

Change .size() to .length()

double netflow = 15.22;
if (doc['category_name'].length() == 0) {
    return null;
} else { 
    if (doc['category_name'].value == 'Router') {
    return netflow;
    }
}

@aaron-nimocks @flash1293
The issue was the normalizer and so the case of the value that was uppercase.
It's working now with my code below.
I didn't change the .size to .length
but may be it's because I always have something ? Do you think my code is not working well and have to change it ?
Thanks a lot for your help

Size didn't work for me but I was defining my own variables and I think size() works for arrays. If it works for you, great.

Length did work.