Skip to content
TheChatArchiveThe Chat Archive
gpt-4-0314· openaiHugging Face Suzhen/CodeChat

elasticsearch put添加数据的 当索引不存在的时候会自动创建索引。 如何不让它自动创建索引

  1. User

    elasticsearch put添加数据的 当索引不存在的时候会自动创建索引。 如何不让它自动创建索引

  2. Assistant

    要在 Elasticsearch 中禁止自动创建索引,需要修改集群的设置。在使用 Elasticsearch 时,我们可以通过修改elasticsearch.yml设置文件或使用集群更新 API 实现。

    方法一: 修改elasticsearch.yml文件

    1. 在 Elasticsearch 安装目录下找到elasticsearch.yml 文件。这个文件通常位于config目录下。

    2. 在文件中添加或更新以下配置:

    action.auto_create_index: false
    
    1. 重启 Elasticsearch 以使设置生效。

    方法二: 使用 Cluster Update API

    运行以下命令来禁用自动创建索引:

    curl -X PUT "localhost:9200/_cluster/settings" -H 'Content-Type: application/json' -d'
    {
        "persistent" : {
            "action.auto_create_index": "false"
        }
    }
    '
    

    这个命令会更新集群的持久设置,禁用自动创建索引。+

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.