Query fails via Java client, successful with elasticsearch-head

Thanks. How would I set username to be not_analyzed using the Java API? I
assume this needs to be done at the time of indexing.