2012-08-15 117 views
3

我不知道我是如何得到我的產品指數,因爲我認爲這就是爲什麼我得到這個錯誤:Elasticsearch和輪胎Gem:「IndexMissingException [[products] missing]」?

Tire::Search::SearchRequestFailed in SearchController#results 

404 : {"error":"IndexMissingException[[products] missing]","status":404} 

這裏是我的產品型號:

class Product < ActiveRecord::Base 
    attr_accessible :name, :description 
    belongs_to :user 

    include Tire::Model::Search 
    include Tire::Model::Callbacks 

    def self.search(params) 
    tire.search(load: true, page: params[:page], per_page: 10) do 
     query { string params[:query]} if params[:query].present? 
    end 
    end 
end 

我如何索引我的產品如果這是問題?

謝謝。

回答

12

運行下面的rake任務

rake environment tire:import CLASS='Product'