多个弹性搜索索引 [英] Multiple Elasticsearch Indexes

查看:150
本文介绍了多个弹性搜索索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个分期& Rails 3应用程序(使用轮胎宝石)的生产实例在同一个Ubuntu服务器上。看来这两个实例都是共享相同的弹性搜索索引,显然这不是我想要的。



如何让我的制作和分段实例使用单独的实例?

解决方案

您需要覆盖索引名称。假设您绑定到ActiveRecord,它将根据所讨论的模型创建一个索引名称。您可以使用如下前缀调整名称:

 类文章< ActiveRecord :: Base 

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

index_prefix#{Rails.env}

...

然后,它将创建一个名为 development_articles production_articles 等。轮胎包含的 index_prefix



或者可以将索引重新命名为

  ActiveRecord :: Base 

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

index_nameMy-Development-Article-Index

...


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?

解决方案

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" 

  ...

这篇关于多个弹性搜索索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆