Elasticsearch Java Library vs. CORS AJAX requests

I have a question regarding the security in Elasticsearch.

I have started a web application using the Elasticsearch Java library and it's been working greatly with me. However, performance/speed wise, isn't it better to use CORS AJAX requests to send a request to Elasticsearch and receive the response instantly? Is it any less secure?