Mongoosastic - {[错误:没有生活的连接]消息:'没有生活的连接'} [英] Mongoosastic - { [Error: No Living connections] message: 'No Living connections' }

查看:184
本文介绍了Mongoosastic - {[错误:没有生活的连接]消息:'没有生活的连接'}的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用mongoosastic进行搜索,但是我不断得到'没有生活的连接'错误和映射问题

Im trying to use mongoosastic for searching purposes, but I keep getting 'No Living connections' error and mapping problem

这里是代码

var mongoose = require('mongoose');
var mongoosastic = require('mongoosastic');
var Schema = mongoose.Schema;


var JobSchema = Schema({
  category: { type: Schema.Types.ObjectId, ref: 'Category', es_indexed:true},
  title: { type: String, es_indexed:true },

});

JobSchema.plugin(mongoosastic);
module.exports = mongoose.model('Job', JobSchema);

routes.js

routes.js

var Job = require('../models/job');

Job.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);
  }
});

app.post('/search', function(req, res, next) {
    Job.search({query_string: {query: req.body.q}}, function(err, results) {
        if (err) return next(err);
        res.send(results);
    });
});

我不断收到此错误,

任何有经验使用mongoosastic的人都会告诉我,我如何解决这个问题?

Can anyone with experience in using mongoosastic tell,me how do i fix this problem?

推荐答案

我也面临同样的问题,但我现在使用以下方法解决

I am also facing same issue but I solved now using below method


它非常简单:您必须在本地或其他地方安装弹性搜索

Its very simple : you have to install elastic search in your local or anywhere else




  1. 下载弹性搜索 http://www.flastic .co / downloads / elasticsearch

  2. 提取文件夹

  3. 从cmd或Treminal find bin转到文件夹文件夹和文件夹内运行弹性搜索脚本

  4. 默认情况下, nodejs 代码将链接到 localhost:9200 ,因此无需使用
    new elasticsearch.Client {host:'localhost:9200'}),但是如果您的弹性搜索合并了某些地方,那么您必须使用客户端方法

  1. Download elastic search http://www.elastic.co/downloads/elasticsearch
  2. Extract folder
  3. go to folder from cmd or Treminal find bin folder and inside that folder run elastic search script
  4. And in nodejs code by default it will link to localhost:9200 so no need to use new elasticsearch.Client({host: 'localhost:9200'}) , but if your elastic search deloyed some where else then you have to use above client method

这篇关于Mongoosastic - {[错误:没有生活的连接]消息:'没有生活的连接'}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆