简体   繁体   English

Searchbox Elasticsearch Heroku没有结果

[英]Searchbox Elasticsearch Heroku No Results

I have a production app on heroku, with the searchbox addon. 我在heroku上有一个生产应用程序,带有搜索框插件。

In my controller I have: 在我的控制器中,我有:

 # GET /venues
  # GET /venues.json
  def index
    @supplier = Supplier.find(current_user.profileable_id)
    @venues = @supplier.venues
  end

And in my model: 在我的模型中:

 include Tire::Model::Search
  include Tire::Model::Callbacks
  index_name("#{Rails.env}")

In my production environment.rb: 在我的生产环境.rb中:

 # Elastic search - Searchbox
  ENV['ELASTICSEARCH_URL'] = ENV['SEARCHBOX_URL']

According to the documentation, that should be all I need. 根据文档,这应该是我所需要的。 However, the addon is not automatically creating the index or mapping. 但是,插件不会自动创建索引或映射。 Without either, heroku logs show a 400 error indicating no index, which it should. 如果没有,heroku日志将显示400错误,表明没有索引,应该这样做。 If I add an index with the name 'production' (based on the #{Rails.env} above) then it doesn't throw any errors, but there are no search results. 如果我添加一个名称为“ production”的索引(基于上面的#{Rails.env}),那么它不会引发任何错误,但是没有搜索结果。 If I then ask Saerchbox to do a crawl of the sites URL, it does some mapping, but is not correct (I know this as we have another instance of the app running elsewhere on heroku, with the same settings and it works fine ie create it's own index and mapping). 如果然后我要求Saerchbox对网站URL进行爬网,则会进行一些映射,但不正确(我知道这一点,因为我们在Heroku上的其他位置运行了该应用程序的另一个实例,设置相同,并且可以正常工作,即创建它是自己的索引和映射)。

What am I missing? 我想念什么? Do I need a heroku run command that i've missed somewhere to create the index? 我是否需要在某处错过的heroku run命令来创建索引?

Ok, worked it out. 好的,解决了。 I needed to run this rake: 我需要运行此耙:

heroku run rake environment tire:import CLASS=Venue FORCE=true

In this case Venue was the model I was indexing, so swap it out for your model when using this. 在这种情况下,Venue是我正在索引的模型,因此在使用它时将其替换为您的模型。

Whilst tire creates indicies automatically in development, it won't in production so you have to force it with a rake. 轮胎虽然会在开发过程中自动创建指标,但不会在生产中使用,因此您必须用耙子强迫它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM