【问题标题】:Reindex ElasticSearch index returns "Incorrect HTTP method for uri [/_reindex] and method [GET], allowed: [POST]"重新索引 ElasticSearch 索引返回“URI [/_reindex] 和方法 [GET] 的 HTTP 方法不正确,允许:[POST]”
【发布时间】:2018-05-14 16:08:40
【问题描述】:

我正在尝试将 elasticsearch 集群从 1.x 升级到 6.x。我正在将远程 1.x 索引重新索引到 6.x 集群中。根据the docs,这是可能的:

要升级 Elasticsearch 1.x 集群,您有两种选择:

  • 对 Elasticsearch 2.4.x 执行完整的集群重启升级并重新索引或删除 1.x 索引。然后,执行完全集群重启升级到 5.6 并重新索引或删除 2.x 索引。最后,滚动升级到 6.x。有关从 1.x 升级到 2.4 的更多信息,请参阅 Elasticsearch 2.4 参考中的升级 Elasticsearch。有关从 2.4 升级到 5.6 的更多信息,请参阅 Elasticsearch 5.6 参考中的升级 Elasticsearch。

  • 创建一个新的 6.x 集群并从远程重新索引以直接从 1.x 集群导入索引。

出于测试目的,我在本地执行此操作,并在 6.x 运行时使用以下命令:

curl --request POST localhost:9200/_reindex -d @reindex.json

我的 reindex.json 文件如下所示:

{
  "source": {
    "remote": {
      "host": "http://localhost:9200"
    },
    "index": "some_index_name",
    "query": {
      "match": {
        "test": "data"
      }
    }
  },
  "dest": {
    "index": "some_index_name"
  }
}

但是,这会返回以下错误:

uri [/_reindex] 和方法 [GET] 的 HTTP 方法不正确,允许:[POST]"

为什么它告诉我不能使用 GET 而是使用 POST?我在这里明确指定了一个 POST 请求,但它似乎认为它是一个 GET 请求。知道为什么会收到错误的请求类型吗?

【问题讨论】:

  • 试试这个curl -XPOST localhost:9200/_reindex --data-binary @reindex.json

标签: elasticsearch


【解决方案1】:

我遇到了同样的问题,但是通过在 PUT 请求中添加设置它起作用了。

PUT /my_blog
{
  "settings" : {
        "number_of_shards" : 1
  },
    "mapping": {
        "post": {
            "properties": {
                "user_id": {
                    "type": "integer"
                },
                "post_text": {
                    "type": "string"
                },
                "post_date": {
                    "type": "date"
                }           
            }
        }
    }
}

你也可以参考这个-https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-30
    • 2020-07-19
    • 2018-12-01
    • 2018-07-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多