I am implementing the suggestions / autocomplete for my search tool built using elasticsearch.
In order to implement the autocomplete, I need to make an ajax call to my elasticsearch instance. But that is giving away my credentials to connect to the elasticsearch.
Following is my code:
$.ajax({
"async": true,
"crossDomain": true,
"url": "http://{userName}:{Password}localhost:9200/{index}/_search",
"method": "POST",
"headers": {
"cache-control": "no-cache",
"content-type": "application/x-www-form-urlencoded",
"Access-Control-Allow-Origin": "*"
},
"data": {
query
}
});