即使在索引模型之后,使用轮胎w / elasticsearch获取IndexMissingException

时间:2013-12-24 20:17:51

标签: ruby elasticsearch tire

尝试运行类似的查询时:

search = Tire::Search::Search.new("retailer")
search.query { string('description:'+store) }
results = search.results.to_ary

我收到错误:404:{“error”:“IndexMissingException [[retailer] missing]”,“status”:404}

我在控制台中使用Retailer.import索引了模型(适用于我编入索引的其他模型)。这实际上最初适用于我的零售商模型,然后很快就开始吐出这个错误。我也试过了

  1. Retailer.index.import Retailer.all,返回“ArgumentError:错误的参数数量(0表示1)”

  2. 和rake任务rake tire:import CLASS=Retailer FORCE=true,返回“rake aborted!uninitialized constant Retailer”

  3. 我的零售商模型如下:

    class Retailer
      include Mongoid::Document
    
      include Tire::Model::Search
      include Tire::Model::Callbacks
    
      mapping do
            indexes :id, :index => :not_analyzed
            indexes :description,  :analyzer => 'snowball'
      end
    
      field :description, :type => String
      field :logo_url, :type => String
      field :url, :type => String
      field :shopzilla_id, :type => String
    
      index :description => 1
    
      has_many :items
      embeds_many :scrape_urls
    
      validates :description, :presence => true
    
      def to_indexed_json
        {
          :id => self.id,
          :description => self.description
        }.to_json
      end
    
    
    ... end
    

    非常感谢对此问题的任何见解,谢谢!

0 个答案:

没有答案