Uncaught TypeError: elasticsearch.Client is not a constructor (elasticsearch.js)

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.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.