Elasticsearch - searching with "keyword" type don't work

I don't know exactly as I don't fully understand what you are doing. It would be better to provide a full recreation script as described in About the Elasticsearch category. It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

Not using Java but just with simple recreation that you can run in Kibana console.

Most likely, when you index a field "foo": "BAR", with a default analyzer, foo is indexed as bar. With a keyword type, it's indexed as BAR.

When running a match query for example on that field, searching for BaR in the former case will transform to bar and it will match.
Searching for BaR in the later case won't match bar.

You can understand all that by using the _analyze API.