Im trying to use Searchkick in my application. However, I get
Searchkick::MissingIndexError
Index missing - run Product.reindex
def search
if params[:search].present?
#product = Product.search(params[:search])
else
#product = Product.all
end
I run Produc.reindex but it didn't solve the issue. I also tried following : rake searchkick:reindex:all and I receive the Reindex complete message which is followed by rake db:migrate; however,I come up with the same missing index error when I submit the search query.
any advice and suggestions will be greatly appreciated
Using Rails 4.1.8 and Elastic Search 2.4.6, I was facing this same problem in the production environment, and when I tried to access the action URL of the autocomplete action I was receiving the same Index missing - run Product.reindex error message. However, in development environment Elastic Search was working without problems.
Usually, I use the following command to reindex my class:
rake searchkick:reindex CLASS=Product
So, following #Aref Aslani comment, I tried this command:
RAILS_ENV=production rake searchkick:reindex CLASS=Product
And it worked!
You can simply launch your Rails Console and then type
Product.reindex
I had a similar error in my application and so I just decided to understand the error message and then tried it on the console as if I am testing a feature and it worked perfectly.
I got same issue in the rails development environment, Rails 5.2.3, ruby 2.4.0, so
resolved it by using the following command:
rails searchkick:reindex CLASS=<ClassName>
like
rails searchkick:reindex CLASS=ThreeDGarment
Related
I am stuck trying to reindex a single model in SearchKick.
If I run the following command:
rails Profile.reindex
I get the following error:
Profile.reindex: command not found
I am able to run the command
rails searchkick:reindex:all
but that takes over an hour because of the size of my other models.
Any help would be appreciated.
Thanks,
Gerard
You can re-index just the Profile class using
rails searchkick:reindex CLASS=Profile
If you just run
rails searchkick:reindex
It will provide the USAGE explanation
Example buried in the Docs
Explanation in the Source Code: Searchkick rake tasks
If you are in the rails console, Profile.reindex should work fine, provided you have set up searchkick in the model.
I have work on project with ruby on rails and i want to use friendly_id gem. When I install friendly_id gem in my project then add following code according to instructions.
controller:
def show
#group = Group.friendly.find(params[:id])
end
Model:
extend FriendlyId
friendly_id :title, use: [:slugged]
I am using rails version 3.2.11 and friendly_id gem is 4.0.0
Getting error in controller. i do not understand why its happening.
error:
undefined method `slug' for #<Group:0x000000092ac228>
Update:
Previous issue solve with restart server and migrating database.
but it generates new issue Couldn't find group with id=new-demo-group
It seems like you need to update the records that are already created, in your case that would be (Group model), as docs says:
If you're adding FriendlyId to an existing app and need to generate
slugs for existing users, do this from the console, runner, or add a
Rake task:
Group.find_each(&:save)
Rails console
Open terminal on the app root and run (-e is the environment)
rails console -e production
You should get a similar output to this (I added the command to run):
Running via Spring preloader in process 5389
Loading production environment (Rails 5.1.5)
2.5.1 :001 > Group.find_each(&:save)
Rails runner
Open terminal on the app root and run (-e is the environment)
rails runner -e production "Group.find_each(&:save)"
I used sunspot_solr and sunspot_rails gem that integrates solr 4 from the following link..
source
Now, when i try to reindex the existing documents, i get a status 500, Internal Server Error..
I removed solr directory and after bundle install, and gave the following commands
rails generate sunspot_rails:install
rake sunspot:solr:run
where am i going wrong? :/
when i tried to reindex in rails console, i got the following error...
when i tried reindexing in rails console, i got the following error..
RSolr::Error::Http: RSolr::Error::Http - 500 Internal Server Error
Error: {'responseHeader'=>{'status'=>500,'QTime'=>10},'error'=>{'trace'=>'java.lang.NullPointerException
at org.apache.solr.update.DocumentBuilder.toDocument(DocumentBuilder.java:232)
at org.apache.solr.update.AddUpdateCommand.getLuceneDocument(AddUpdateCommand.java:73)
at org.apache.solr.update.DirectUpdateHandler2.addDoc(DirectUpdateHandler2.java:204)
at org.apache.solr.update.processor.RunUpdateProcessor.processAdd(RunUpdateProcessorFactory.java:69)
at org.apache.solr.update.processor.UpdateRequestProcessor.processAdd(UpdateRequestProcessor.java:51)
at org.apache.solr.update.processor.DistributedUpdateProcessor.doLocalAdd(DistributedUpdateProcessor.java:451)
at org.apache.solr.update.processor.DistributedUpdateProcessor.versionAdd(DistributedUpdateProcessor.java:587)
at org.apache.solr.update.processor.DistributedUpdateProcessor.processAdd(DistributedUpdateProcessor.java:346)
at org.apache.solr.update.processor.LogUpdateProcessor.processAdd(LogUpdateProcessorFactory.java:100)
at org.apache.solr.handler.loader.XMLLoader.processUpdate(XMLLoader.java:246)
The stopwords were causing the problems... i had to do some changes in the schema.xml(as i used ngrams in my project) and fixed the stopwards problem.. now its working fine :)
I'm trying to deploy my first app with rails. I'm unable to deploy it, and I'm unhappy because the framework itself allowed me to develop really quickly the application, but I've only two days to make the deployment work :-(
I've installed and configured passenger following a tutorial (i'm using RVM).
When I access the page I have the following error page: traceback here (posted on pastebin to keep this post clear).
What is wrong?
i just uploaded the whole project on the production server, ran bundle install, rake db:create rake db:migrate and rake db:seed. Am I missing some step?
Why it doesn't run?
Developed using Rails 3.2.3 with Ruby 1.9.3.
Please help me to get it running.
Thanks,
Alex.
I have very little information about your problem but I have and idea what is going on. Check your belongs_to association in your event model if there is a class parameter replace it with class_name.
i wrote a script to fill a database using values from an excel page. In the script I'm getting the error
uninitialized constant Profile (NameError)
Profile is the name of a model i have. Rails looks it is not recognizing my model in the script. How can fix this.
It looks like Rails doesn't get properly initialized.
Can you post the script, and explain how you run / start it?
Which version of Rails do you use?
If you have a rails application and you want to run a task as a script, there are two ways to do it:
1) via script runner
2) via rake
If you use rake, you have to tell it to initialize your Rails application properly.
The rake tasks need to be under ./lib/tasks
Check out these Posts, which explain how to do it:
I have a Rails task: should I use script/runner or rake?
script/runner in rails 3
http://guides.rubyonrails.org/active_record_querying.html