Search code examples
node.jselasticsearchmongoosemongoosastic

mongoosesastic no living connection


I'm trying to insert my mongoose scheme into elasticsearch with mongoosastic but it gives me { [Error: No Living connections] message: 'No Living connections' }

my mongoose schema:

var mongoose = require( 'mongoose' );
var Schema = mongoose.Schema;
var mongoosastic = require('mongoosastic');
var ProductSchema = new Schema( {
   ----huge load of json----
});

ProductSchema.plugin(mongoosastic,{host:'xxx.xxx.xxx.xxx:9200',curlDebug: true});

mongoose.model('product', ProductSchema);

var product = mongoose.model('product');
product.createMapping(function(err, mapping){
if(err){
    console.log('error creating mapping (you can safely ignore this)');
    console.log(err);
}else{
    console.log('mapping created!');
    console.log(mapping);
}
});
module.exports = product;

I can curl to the elasticsearch server, so no issue there


Solution

  • Fixed it by passing my ip in an array

    ProductSchema.plugin(mongoosastic,{
    hosts: [
        'XXX.XXX.XXX.XXX:9200'
     ]
    });
    

    must be a bug in mongoosastic