ruby-on-railsruby-on-rails-3elasticsearchtire

Elasticsearch and Tire Gem: "IndexMissingException[[products] missing]"?


I'm not sure how I get my products to index because I think thats why I get this error:

Tire::Search::SearchRequestFailed in SearchController#results

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

Here is my Products Model:

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

How do I index my products if this is the issue?

Thank you.


Solution

  • Run the following rake task

    rake environment tire:import CLASS='Product'