Reputation: 23
First the important information. I have a development machine that is running Ubuntu 14.04 desktop, MySQL server 5.6 and ruby 2.1.3 with rails 4.2.0.beta2. I developed an application with two simple tables in MySQL called users and listings. My app works beautifully on this machine. I am now migrating it to the production machine. Only major difference in configuration is that it is running the server edition of Ubuntu and not desktop. Same version though. After configuring that machine I checked out my app from source control to production. When setting up the database I was able to perform rake db:create and rake db:schema:load without issue. I have verified this through running sql queries directly to mysql. My problem is that I can not insert any data through my rails application.
Note I still need to configure Phusion and Apache completely so I am running from command line and console right now. I have not tested through my pages yet.
When I attempted to seed the users table with just one record database using
bundle exec rake db:seed
I get the following error:
ArgumentError: users does not exist to be imported into. Use create_index! or the :force option to create it.
Again when I check it directly querying mysql it does have that table. When I run a trace on it I get:
** Invoke db:seed (first_time)
** Execute db:seed
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:abort_if_pending_migrations
rake aborted!
I tried to use the rails console to input the data directly (names and data values changed to protect the innocent)
2.1.3 :001 > u=User.create :userid => 1, :firstname => "FName", :lastname => "LName", :email => "[email protected]", :title => "Research Scientist", :department => "PSC", :building => "Big Hall", :officenumber => "123", :phonenumber => "555-555-5555", :password => "my password", :password_confirmation => "my password", :admin => true
This gave me the same failure:
I am completely stymied as to what is failing here. I am including my Gemfile on the chance that someone sees something there but again this same file works perfectly on development.
source 'http://rubygems.org'
ruby '2.1.3'
#ruby-gemset=pfinder
gem 'rails', '4.2.0.beta2'
gem 'sass-rails', '5.0.0.beta1'
gem 'bootstrap-sass', '3.2.0.0'
gem 'sprockets', '2.12.2'
gem 'bcrypt', '3.1.7'
gem 'faker', '1.4.2'
gem 'will_paginate', '3.0.7'
gem 'bootstrap-will_paginate', '0.0.10'
gem 'mini_portile', '0.6.0'
gem 'uglifier', '2.5.3'
gem 'coffee-rails', '4.0.1'
gem 'jquery-rails', '3.1.2'
gem 'turbolinks', '2.3.0'
gem 'jbuilder', '2.1.3'
gem 'rails-html-sanitizer', '1.0.1'
gem 'sdoc', '0.4.0', group: :doc
gem 'yaml_db'
gem 'json'
gem 'elasticsearch-model', git: 'git://github.com/elasticsearch/elasticsearch- rails.git'
gem 'elasticsearch-rails', git: 'git://github.com/elasticsearch/elasticsearch-rails.git'
gem 'mysql2', '0.3.18'
Thank you in advance for any advice on chasing this down.
Kris
Upvotes: 2
Views: 724
Reputation: 2129
You need to create the index. Like this:
$ rails console
# Create the index for the User model
> User.__elasticsearch__.create_index!
=> {"acknowledged"=>true}
# Import the records
> User.import
User Load (3.2ms) SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT 1000
The official documentation is here: https://github.com/elastic/elasticsearch-rails/tree/master/elasticsearch-model
Upvotes: 2