Django - update_index更新测试和生产站点

问题描述 投票:0回答:1

这是一个奇怪的,我无法弄清楚。

我有两个数据库 - 测试和生产。

我有两个网站 - 测试和制作。

Django正在使用elasticsearch进行索引。

它们运行不同的服务器,具有不同的IP地址等。

两个数据库之间根本没有链接。它们是独立维护的。

但是,当我在生产或测试站点上运行update_indexrebuild_index时,BOTH站点上的索引正在获取更新。这两个数据库仍然保持独立,并且根本没有传输数据。

如果我在测试或生产上运行命令并不重要 - 两者都将从任一源更新。

这显然给我带来了许多问题,我不能为我的生活弄清楚。

测试数据库和HAYSTACK连接 -

DATABASES = {
    "default": {
        # Ends with "postgresql_psycopg2", "mysql", "sqlite3" or "oracle".
        "ENGINE": "django.db.backends.oracle",
        # DB name or path to database file if using sqlite3.
        "NAME": "--",
        # Not used with sqlite3.
        "USER": "--",
        # Not used with sqlite3.
        "PASSWORD": "--",
        # Set to empty string for localhost. Not used with sqlite3.
        "HOST": <test-database>,
        # Set to empty string for default. Not used with sqlite3.
        "PORT": "--",
    }
}

HAYSTACK_CONNECTIONS = {
    'default': {
        'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
        'URL': 'http://127.0.0.1:9200',
        'INDEX_NAME': 'products_index'
    }
}

生产数据库和HAYSTACK连接

DATABASES = {
    "default": {
        # Ends with "postgresql_psycopg2", "mysql", "sqlite3" or "oracle".
        "ENGINE": "django.db.backends.oracle",
        # DB name or path to database file if using sqlite3.
        "NAME": "--",
        # Not used with sqlite3.
        "USER": "--",
        # Not used with sqlite3.
        "PASSWORD": "--",
        # Set to empty string for localhost. Not used with sqlite3.
        "HOST": "<production-database>",
        # Set to empty string for default. Not used with sqlite3.
        "PORT": "--",
    }
}
HAYSTACK_CONNECTIONS = {
  'default': {
  'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
  'URL': 'http://127.0.0.1:9200/',
  'INDEX_NAME': 'products_index',
  },
}

我一直在撕扯我的头发,似乎无法找到两者如何沟通和更新对方!谁能帮我吗?

django elasticsearch django-haystack
1个回答
0
投票

测试和生产服务器指向同一ES服务器。希望能回答你的问题。

© www.soinside.com 2019 - 2024. All rights reserved.