【问题标题】:Unable to create index in Elastic search using API无法使用 API 在弹性搜索中创建索引
【发布时间】:2020-09-06 08:05:25
【问题描述】:

我正在尝试使用 API 在 kibana 开发工具中使用以下映射在 Elasticsearch 中创建索引。创建索引后,我想使用 reindex API 从现有索引中复制文档。

        PUT /ipflow-logs
        {
          "ipflow-logs" : {
            "mappings" : {
              "properties" : {
                "conn_state" : {
                  "type" : "keyword"
                },
                "content_length" : {
                  "type" : "long"
                },
                "content_type" : {
                  "type" : "keyword"
                },
                "createdDate" : {
                  "type" : "keyword"
                },
                "dst_ip" : {
                  "type" : "ip"
                },
                "dst_port" : {
                  "type" : "long"
                },
                "duration" : {
                  "type" : "long"
                },
                "history" : {
                  "type" : "keyword"
                },
                "local_orig" : {
                  "type" : "keyword"
                },
                "missed_bytes" : {
                  "type" : "long"
                },
                "orig_bytes" : {
                  "type" : "long"
                },
                "orig_ip_bytes" : {
                  "type" : "long"
                },
                "orig_pkts" : {
                  "type" : "long"
                },
                "protocol" : {
                  "type" : "keyword"
                },
                "resp_bytes" : {
                  "type" : "long"
                },
                "resp_ip_bytes" : {
                  "type" : "long"
                },
                "resp_pkts" : {
                  "type" : "long"
                },
                "service" : {
                  "type" : "keyword"
                },
                "src_ip" : {
                  "type" : "ip"
                },
                "src_port" : {
                  "type" : "long"
                },
                "timestamp" : {
                  "type" : "date",
                  "format" : "yyyy-MM-dd 'T' HH:mm:ss.SSS"
                },
                "uid" : {
                  "type" : "keyword"
                }
              }
            }
          }
        }

我在尝试创建索引时收到以下错误。

“type”:“parse_exception”,“reason”:“创建索引的未知键[ipflow-logs]”,“status”:400

感谢任何帮助。谢谢

【问题讨论】:

    标签: api elasticsearch indexing kibana-5


    【解决方案1】:

    你需要这样做(即mappings应该在顶部):

    PUT /ipflow-logs
    {
      "mappings": {
        "properties": {
          "conn_state": {
            "type": "keyword"
          },
          "content_length": {
            "type": "long"
          },
          "content_type": {
            "type": "keyword"
          },
          "createdDate": {
            "type": "keyword"
          },
          "dst_ip": {
            "type": "ip"
          },
          "dst_port": {
            "type": "long"
          },
          "duration": {
            "type": "long"
          },
          "history": {
            "type": "keyword"
          },
          "local_orig": {
            "type": "keyword"
          },
          "missed_bytes": {
            "type": "long"
          },
          "orig_bytes": {
            "type": "long"
          },
          "orig_ip_bytes": {
            "type": "long"
          },
          "orig_pkts": {
            "type": "long"
          },
          "protocol": {
            "type": "keyword"
          },
          "resp_bytes": {
            "type": "long"
          },
          "resp_ip_bytes": {
            "type": "long"
          },
          "resp_pkts": {
            "type": "long"
          },
          "service": {
            "type": "keyword"
          },
          "src_ip": {
            "type": "ip"
          },
          "src_port": {
            "type": "long"
          },
          "timestamp": {
            "type": "date",
            "format": "yyyy-MM-dd 'T' HH:mm:ss.SSS"
          },
          "uid": {
            "type": "keyword"
          }
        }
      }
    }
    

    【讨论】:

    • 感谢@Val,删除上面映射的 ipflow-logs 解决了这个问题。我能够创建索引。
    • 太棒了,很高兴它有帮助!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-07
    • 2018-07-15
    • 2019-09-28
    • 2022-08-17
    • 2021-10-27
    相关资源
    最近更新 更多