3

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

Nick
  • 575
  • 10
  • 29
  • No living connections usually mean that your code cannot reach your ES server. Have you tried to restart your ES server by any chance? – Val May 12 '15 at 03:10
  • yes I tried, no success :( – Nick May 12 '15 at 14:15
  • Are you sure you instantiated your plugin correctly? Shouldn't you create an elasticsearch client first, like this? `var esClient = new elasticsearch.Client({host: 'localhost:9200'}); productSchema.plugin(mongoosastic, { esClient: esClient })` – Val May 12 '15 at 15:37
  • Also what do you see when you run this in a shell `curl -XGET http://xxx.xxx.xxx.xxx:9200` ? (make sure to use the correct host or IP address) – Val May 12 '15 at 15:41
  • @Val You are right. after creating the client i got `[TypeError: Invalid index: expected be a comma seperated list, array, number or string.]` 'instead of the no living connections error :) *it's something* – Nick May 12 '15 at 17:22
  • @Val curl output is `{ "status" : 200, "name" : "Madelyne Pryor", "cluster_name" : "thiscluster", "version" : { "number" : "1.5.2", "build_hash" : "62ff9868b4c8a0c45860bebb259e21980778ab1c", "build_timestamp" : "2015-04-27T09:21:06Z", "build_snapshot" : false, "lucene_version" : "4.10.4" }, "tagline" : "You Know, for Search" }` – Nick May 12 '15 at 17:26

1 Answers1

3

Fixed it by passing my ip in an array

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

must be a bug in mongoosastic

Nick
  • 575
  • 10
  • 29
  • 1
    I was using the configuration in the require call, (require('mongoosastic', {..config}) and doesn't work. I changed to each plugin call like you say and worked fine. Thanks – Herlon Aguiar May 15 '17 at 16:22