ncb000gt / node-es

NodeJS module for ElasticSearch.
103 stars 81 forks source link

Setting options dynamically #62

Closed omundy closed 8 years ago

omundy commented 8 years ago

This example from the README which sets the index dynamically does not appear to work. It always returns undefined. Am I doing something wrong? See comments...

var hapi = require('hapi');
var server = new hapi.Server();

var elasticsearch = require('es'),
    config = {
      _index : 'dogs',
      _type : 'dog'
    },
    es = elasticsearch(config);

server.connection({ port: 3300, host: 'localhost' });

server.route({
    method: 'GET',
    path: '/',
    handler: function (request, reply) {

        // this works
        es.count(function (err, data) {
            console.log(data);
        });

        // setting options dynamically does not
        var options = {
            _index : 'cats',
            _type : 'cat'
        }
        es.count(options, function (err, data) {
            console.log(data);
        });

    }
});

server.start(function (err) {
    if (err) {
        throw err;
    }
  console.log('hapi server started');
});
brozeph commented 8 years ago

@omundy - my apologies for the long delay on a fix... this is now repaired in v0.5.2