Thirld line of the function show Uncaught TypeError: elasticsearch.Client is not a constructor
I do not know why it is like this
function newAutocomplete(){
var elasticsearch = 'elasticsearch';
require([elasticsearch], function (elasticsearch) {});
var esclient = new elasticsearch.Client({
host: 'localhost:9200',
log: 'trace'
});
esclient.search({
index: 'user',
body: {
query:{
match_all: {}
}
}
}).then(function (resp) {
var hits = resp.hits.hits;
}, function (err) {
console.trace(err.message);
});
$('#query_input').autocomplete({
source: availableSuggs
});
}
Any help would be really appreciated.