不知何故,在Elasticsearch映射中定义一个点场型并导入数据是可能的,但两者都不能。在JSON数据中,位置字段如下所示
"location": {
"lat": 41.12,
"lng": -71.34
}因为我们需要"lon“而不是"lng”,所以我们在Logstash配置中使用这个“可变”过滤器来重命名该字段:
mutate {
rename => {
"[location][lng]" => "[location][lon]"
}
}如果我们不使用映射,那么Elasticsearch将自动对位置字段使用以下映射并导入数据
"location": {
"properties": {
"lat": {
"type": "float"
},
"lon": {
"type": "float"
}
}
}到目前一切尚好。但是,如果我在创建索引时在Elasticsearch映射中使用“geo_point”,那么我就不能再导入任何数据了,因为如果我们试图更改映射,就会得到“无法将非对象映射位置与对象映射合并”的错误消息。但是在这里,映射已经被用来创建索引:
"mappings":{
"properties":{
"location": {
"type": "geo_point",
"ignore_malformed": "true",
},
}
}显然,Logstash和Elasticsearch将在映射中具有geo_point类型的字段geo_point看作不是对象,而该位置的JSON数据是一个对象。
虽然无法使用此映射导入Logstash中的数据,但我可以将文档保存在Kibana DEV工具中,例如
PUT geo-test/_doc/1
{
"title": "Geo-point test",
"location": {
"lat": 41.12,
"lon": -71.34
}
}如何使用地理点映射在Logstash中导入数据?(我使用的是Elasticsearch版本7.9.1和Logstash版本7.12.0,包括S3输入插件和Elasticsearch输出插件)
发布于 2021-06-23 14:13:23
获得此错误的原因是您在document_type输出中指定了不同的elasticsearch。只要去掉下面强调的线,它就会像你所期望的那样工作:
elasticsearch {
hosts => [ "${ES_DOMAIN_NAME}:443" ]
healthcheck_path => "/"
ilm_enabled => false
ssl => true
index => "${ES_INDEX}"
document_type => "json" <--- remove this line
}您安装的映射用于默认文档类型,即_doc而不是json。
https://stackoverflow.com/questions/68094162
复制相似问题