1

我正在尝试将日志从 logstash 流式传输到 elasticsearch(5.5.0)。我正在使用 filebeat 将日志发送到 logstash。

我没有定义任何索引;它是在第一次推送数据时自动定义的(比如“test1”)。

现在,我想创建另一个索引(“test2”),以便我可以管理字段数据类型。为此,我得到了 test1 的映射。更新了索引名称。并且 PUT 是否使用此数据调用了 test2。但是,它失败并显示以下结果:

`ubuntu@elasticsearch:~$ curl -XPUT 'localhost:9200/test2?pretty' -H 'Content-Type: application/json' -d'@/tmp/mappings_test.json'

{
  "error" : {
  "root_cause" : [
    {
      "type" : "illegal_argument_exception",
      "reason" : "unknown setting [index.test2.mappings.log.properties.@timestamp.type] please check that any required plugins are installed, or check the breaking changes documentation for removed settings"
    }
  ],
  "type" : "illegal_argument_exception",
  "reason" : "unknown setting [index.test2.mappings.log.properties.@timestamp.type] please check that any required plugins are installed, or check the breaking changes documentation for removed settings"
  },
  "status" : 400
}

`

以下是我正在使用的 json 的摘录。`

{
  "test2" : {
    "mappings" : {
      "log" : {
        "properties" : {
          "@timestamp" : {
             "type" : "date"
           },
        "@version" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
         }
      },
        "accept_date" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
....

`

我只修改了索引名称。其余内容同 test1 索引的映射。

对于如何通过更新类型来创建这个新索引有任何帮助吗?

4

1 回答 1

3

您需要test2在第二行删除并且只有mappings

PUT test2
{
    "mappings" : {              <---- this needs to be at the top level
      "log" : {
        "properties" : {
          "@timestamp" : {
             "type" : "date"
           },
        "@version" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
         }
      },
        "accept_date" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
....
于 2017-07-13T08:18:44.927 回答