Algolia:initialize not working (rails aborted - don't know how to build task)

Hi,
I would like to setup our discourse with algolia, but it is not working like described on GitHub. I have newest version: 3.0.0.beta16.

To make first init, I open my discourse-docker with

./launcher enter app

After that, I tried different commands (bundle exec rails or only rails, also rake), but all results into:

root@rbx-communtity-service-app:/var/www/discourse# LOAD_PLUGINS=1 rails algolia:initialize
rails aborted!
Don’t know how to build task ‘algolia:initialize’ (See the list of available tasks with rails --tasks)
Did you mean? algolia:reindex

When I run just algolia:reindex, i get the following:

root@rbx-communtity-service-app:/var/www/discourse# LOAD_PLUGINS=1 rake algolia:reindex
Clearing users from Algolia
Pushing users to Algolia
..
Successfully pushed xxx users to Algolia
Clearing tags from Algolia
Pushing tags to Algolia
..
Successfully pushed xxx tags to Algolia
Clearing posts from Algolia
Pushing posts to Algolia
rake aborted!
NoMethodError: undefined method `id' for nil:NilClass
/var/www/discourse/plugins/discourse-algolia/lib/discourse_algolia/post_indexer.rb:66:in `to_object'
/var/www/discourse/plugins/discourse-algolia/lib/discourse_algolia/indexer.rb:23:in `block in process!'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3.1/lib/active_record/relation/batches.rb:71:in `each'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3.1/lib/active_record/relation/batches.rb:71:in `block in find_each'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3.1/lib/active_record/relation/batches.rb:138:in `block in find_in_batches'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3.1/lib/active_record/relation/batches.rb:245:in `block in in_batches'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3.1/lib/active_record/relation/batches.rb:229:in `loop'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3.1/lib/active_record/relation/batches.rb:229:in `in_batches'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3.1/lib/active_record/relation/batches.rb:137:in `find_in_batches'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3.1/lib/active_record/relation/batches.rb:70:in `find_each'
/var/www/discourse/plugins/discourse-algolia/lib/discourse_algolia/indexer.rb:21:in `process!'
/var/www/discourse/plugins/discourse-algolia/lib/tasks/discourse_algolia.rake:36:in `block in algolia_reindex'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3.1/lib/active_record/relation/batches.rb:245:in `block in in_batches'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3.1/lib/active_record/relation/batches.rb:229:in `loop'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3.1/lib/active_record/relation/batches.rb:229:in `in_batches'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3.1/lib/active_record/querying.rb:22:in `in_batches'
/var/www/discourse/plugins/discourse-algolia/lib/tasks/discourse_algolia.rake:33:in `algolia_reindex'
/var/www/discourse/plugins/discourse-algolia/lib/tasks/discourse_algolia.rake:7:in `block in <main>'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/bundler-2.4.1/lib/bundler/cli/exec.rb:58:in `load'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/bundler-2.4.1/lib/bundler/cli/exec.rb:58:in `kernel_load'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/bundler-2.4.1/lib/bundler/cli/exec.rb:23:in `run'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/bundler-2.4.1/lib/bundler/cli.rb:491:in `exec'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/bundler-2.4.1/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/bundler-2.4.1/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/bundler-2.4.1/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/bundler-2.4.1/lib/bundler/cli.rb:34:in `dispatch'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/bundler-2.4.1/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/bundler-2.4.1/lib/bundler/cli.rb:28:in `start'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/bundler-2.4.1/exe/bundle:45:in `block in <top (required)>'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/bundler-2.4.1/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/bundler-2.4.1/exe/bundle:33:in `<top (required)>'
/usr/local/bin/bundle:25:in `load'
/usr/local/bin/bundle:25:in `<main>'
Tasks: TOP => algolia:reindex
(See full trace by running task with --trace)

Any idea whats the issue here?

Thanks in advance!
Marcel

Hey @anderson ,

Believe it or not, we run our Discourse as a managed in instance from the Discourse folks, so I don’t have a lot of visibility into the inner workings of the integration.

Looking at the repo for the plugin, it looks like you may have some luck reaching out to our friends at Discourse:

Hi,
I have written a question to official Discourse-Support and they confirmed that support now needs to be on there side. So if anyone other has an issue regarding the discourse-algolia-plugin, you can ask on discourse support, like mentioned by there team.

Since discourse-algolia is an official plugin, it is supported by Discourse. We’ve removed the confusing “support” section in the README.

Thanks,
Marcel

1 Like