Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Errno::ECONREFUNCE在ArticlesControllerindex中出错?用于弹性搜索和轮胎宝石。我如何让我的搜索工作?_Ruby On Rails_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch_Tire - Fatal编程技术网 elasticsearch,tire,Ruby On Rails,elasticsearch,Tire" /> elasticsearch,tire,Ruby On Rails,elasticsearch,Tire" />

Ruby on rails Errno::ECONREFUNCE在ArticlesControllerindex中出错?用于弹性搜索和轮胎宝石。我如何让我的搜索工作?

Ruby on rails Errno::ECONREFUNCE在ArticlesControllerindex中出错?用于弹性搜索和轮胎宝石。我如何让我的搜索工作?,ruby-on-rails,elasticsearch,tire,Ruby On Rails,elasticsearch,Tire,我正在尝试包括对我的文章的搜索。我正在使用ElasticSearch和Tire gem,试图遵循RailsCast 306中的步骤。 当我尝试搜索时,会出现以下错误: Errno::ECONNREFUSED in ArticlesController#index Connection refused - connect(2) Extracted source (around line #13): def index if params[:query].present?

我正在尝试包括对我的文章的搜索。我正在使用ElasticSearch和Tire gem,试图遵循RailsCast 306中的步骤。 当我尝试搜索时,会出现以下错误:

Errno::ECONNREFUSED in ArticlesController#index
Connection refused - connect(2)

Extracted source (around line #13):     
 def index
    if params[:query].present?
    @articles = Article.search(params[:query]).paginate(page: params[:page])
else
    @articles = Article.paginate(page: params[:page])
end
我如何解决这个问题

以下是我的文章模型:

class Article < ActiveRecord::Base
include Tire::Model::Search
include Tire::Model::Callbacks
has_many :comments
has_many :taggings
has_many :tags, through: :taggings
mount_uploader :picture, PictureUploader
self.per_page = 4
def tag_list
self.tags.collect do |tag|
tag.name
end.join(", ")
end
def tag_list=(tags_string)
tag_names = tags_string.split(",").collect{|s| s.strip.downcase}.uniq
new_or_found_tags = tag_names.collect { |name| Tag.find_or_create_by(name: name) }
self.tags = new_or_found_tags
end
def picture_size
if picture.size > 5.megabytes
errors.add(:picture, "should be less than 5MB")
end
end
WillPaginate.per_page = 4
end
以下是我的文章:

 class ArticlesController < ApplicationController
  before_filter :require_login, except: [:show, :index]
 def index
    if params[:query].present?
    @articles = Article.search(params[:query]).paginate(page: params[:page])
else
    @articles = Article.paginate(page: params[:page])
end
 #@articles = Article.paginate(page: params[:page])
  #@articles_by_month = Article.find(:all).group_by { |post| post.created_at.strftime("%B") }
  @posts = Article.order("created_at DESC")
 end
def show
  @article = Article.find(params[:id])
  @comment = Comment.new
 @comment.article_id = @article.id
end
def new
 @article = Article.new
end
def create
 @article = Article.new(article_params)
 @article.save
 redirect_to article_path(@article)
end
def edit
 @article = Article.find(params[:id])
end
def destroy
 @article = Article.find(params[:id])
 @article.destroy
 redirect_to articles_path
end
def update
 @article = Article.find(params[:id])
 @article.update(article_params)
 flash.notice = "Article '#{@article.title}' Updated!"
 redirect_to article_path(@article)
end
如何让搜索工作正常进行?
谢谢

这表明elasticsearch没有运行,或者您的rails应用程序没有成功连接到它。谢谢Shadwell,您知道我应该怎么做吗?我不熟悉railscast,但我认为它提到安装和运行elasticsearch。如果不是的话,我很确定轮胎文档中包含了它。