我想使用ElasticSearch + Tire搜索存儲在MongoDB中。Ruby:ElasticSearch +輪胎錯誤輪胎:: Search :: SearchRequestFailed - IndexMissingException?
不過,我得到以下錯誤,當我嘗試執行搜索:
輪胎::搜索:: SearchRequestFailed在SearchController#指數
404 : {"error":"IndexMissingException[[events] missing]","status":404}
據我瞭解,這告訴我事件中缺少索引,即使我在運行db:setup
時告訴它產生它們。
型號:
class Event
include Mongoid::Document
include Mongoid::Timestamps
include Tire::Model::Search
include Tire::Model::Callbacks
field :name, :type => String
field :description, :type => String
field :started_at => Time
field :ended_at => Time
def to_indexed_json
self.as_json
end
end
控制器:
def search
Event.tire.search(params[:q])
end
任何想法如何解決這個嗎?
請更新模型 - 我沒有看到任何'field'定義。總而言之,當你加載應用程序時,應該創建它,除非它已經存在。 – karmi 2012-04-20 07:31:56
@karmi:我已經將模型添加到模型中了。 – gabriel 2012-04-22 20:10:20
我意識到問題在於保存模型時未將模型添加到ElasticSearch索引中。我嘗試手動添加/導入它,但我似乎無法得到它的工作...任何幫助解決這個將不勝感激。 – gabriel 2012-04-22 20:11:29