Field.keyword is not getting populated with the values from field

Hi Folks,

I am trying to create a visualize in Kibana which will have a URL which will be formatted using the value in the field something like this:

https://dashboard?branch={{value}}&id=CPP

But I can see the value populated in my field cpp_sonar_url but when I try to format URL with cpp_sonar_url.keyword, it is coming out empty in the "Data table" visualize when aggregated as "terms".

Screen Shot 2021-06-10 at 1.09.04 PM

The URL in the dashboard shows something like this(without branch populated):

https://dashboard?branch=&id=CPP

I have to use .keyword because the visualize only shows the .keyword field and not the actual field.

I have been using the same logic for other fields and it is working fine for them but not for this one so not sure what is different about this and how can I debug it to make it work.

Any pointers will be really helpful.

I created a new keyword type field but that also show value during Discover but not during visualize then aggregation then terms.

Do you mean this works for other .keyword fields, but doesn't work only for this particular .keyword field?
If it is not working for any .keyword, then this definitely sounds like a bug, and I'd open a bug issue: https://github.com/elastic/kibana/issues/new?assignees=&labels=bug&template=Bug_report.md