Multiple Elasticsearch Indexes

老子叫甜甜 提交于 2019-12-24 10:46:50

问题


I have a staging & production instance of a Rails 3 application (using the tire gem) on the same Ubuntu server. It appears that both of these instances are sharing the same elasticsearch index which obviously isn't what I want.

How can I get my production and staging instances to use separate instances?


回答1:


You need override the index name. Assuming you're tying into ActiveRecord it will create an index name based on the model in question. You could adjust the name with a prefix like so;

class Article < ActiveRecord::Base

  include Tire::Model::Search
  include Tire::Model::Callbacks

  index_prefix "#{Rails.env}" 

  ...

which would then create an index named development_articles, production_articles etc. It's important the the index_prefix comes after the Tire includes.

Or alternatively rename the index entirely

class Article < ActiveRecord::Base

  include Tire::Model::Search
  include Tire::Model::Callbacks

  index_name "My-Development-Article-Index" 

  ...


来源:https://stackoverflow.com/questions/11404637/multiple-elasticsearch-indexes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!