【问题标题】:Not Able to generate geo_point field with geo_point data type Logstash无法生成 geo_point 数据类型为 Logstash 的 geo_point 字段
【发布时间】:2020-07-30 07:50:09
【问题描述】:

我正在尝试使用 logstash 从 mysql 表 ES 索引加载数据。我能够将数据加载到 ES 中,但位置字段映射不是作为 geo_point 类型出现的。它显示为关键字类型。所以我无法查询 geo_point 字段。

任何帮助是什么问题? ES 版本:6.7.0

这是我的template.json 文件:

{
    "settings" :
    {
        "number_of_shards" : 1,
        "codec": "best_compression",
        "number_of_replicas" : 0,
        "index.translog.flush_threshold_size": "2g",
        "bootstrap.mlockall": true,
        "indices.fielddata.cache.size": 25%
    },
    "mappings":
    {
            "_doc" :
            '|            "dynamic_templates":
              [
                  {
                      "message_field": {
                        "path_match": "message",
                        "match_mapping_type": "string",
                        "mapping": {
                          "type": "text",
                          "norms": false
                        }
                      }
                    },
                    {
                      "string_fields": {
                        "match": "*",
                        "match_mapping_type": "string",
                        "mapping": {
                          "type": "text",
                          "norms": false,
                          "fields": {
                            "keyword": {
                              "type": "keyword",
                              "ignore_above": 256
                            }
                          }
                        }
                      }
                    }
              ],
"properties" : {
                "@timestamp": {
                     "type": "date"
                },
                "@version": {
                     "type": "keyword"
                },
                "location": {
                     "type": "geo_point"
                },
                "lat" : { "type" : "keyword", "index" : "not_analyzed","index_options" : "docs" },
                "lon" : { "type" : "keyword", "index" : "not_analyzed","index_options" : "docs" }
              }
            }
    }
}

logstash.conf 文件输入

{
        jdbc {
                ..........
    }
}
filter
{
    mutate {
        convert => { "lon" => "float" }
        convert => { "lat" => "float" }
        rename => {
            "lon" => "[location][lon]"
            "lat" => "[location][lat]"
        }
    }
}
output {
  elasticsearch {
        hosts => "host:80"
        index => "my_index"
        manage_template => "false"
        document_type => "_doc"
        template_name=>"template.json"
        document_id => "%{id}"
  }
}

【问题讨论】:

  • 你能展示一下你在运行GET my_index时得到了什么吗?
  • 还要设置manage_template => "true"否则模板将不会被加载
  • GET my_index->​​ 给出 "location" : { "properties" : { "lat" : { "type" : "float" }, "lon" : { "type" : "float" } } }
  • 是的,请看下面我的回答,您的模板没有被应用

标签: elasticsearch logstash elasticsearch-5 aws-elasticsearch


【解决方案1】:

我认为您只是缺少manage_template => true,您也可以添加template_overwrite => true 以确保模板被覆盖:

  elasticsearch {
        hosts => "host:80"
        index => "my_index"
        manage_template => "true"             <---- change this
        template_overwrite => true            <---- also add this
        document_type => "_doc"
        template_name=>"template.json"
        document_id => "%{id}"
  }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-08-31
    • 2016-08-13
    • 1970-01-01
    • 1970-01-01
    • 2015-10-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多