logstash filter 处理geo_point

参考,es的mapping和字段类型 :https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html

参考,logstash的fileter插件:https://www.elastic.co/guide/en/logstash/current/filter-plugins.html

参考,es 的地理查询:https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-bounding-box-query.html

 

 

ES设置mapping

PUT poi-003
{
  "mappings": {
    "properties": {
      "@timestamp":{
        "type": "date"
      },
      "@version":{
        "type":"keyword"
      },
      "name":{
        "type": "text",
        "fields": {
          "keyword":{
            "type":"keyword",
            "ignore_above":256
          }
        }
      },
      "address":{
        "type": "text",
        "fields": {
          "keyword":{
            "type":"keyword",
            "ignore_above":256
          }
        }
      },
      "typecode":{
        "type": "text",
        "fields": {
          "keyword":{
            "type":"keyword",
            "ignore_above":256
          }
        }
      },
      "x":{
        "type": "float"
      },
      "y":{
        "type": "float"
      },
      "location":{
        "type": "geo_point"
      }
    }
  }
}

 

logstash的配置文件

input {
	stdin { } 
	file {
		path => ["/home/aganliang/es/downloads/logstash-7.6.2/myconfig/data/poi-3.json"]
		start_position => "beginning" 
		sincedb_path => "/dev/null"
	}
}

filter {
    json {
	    source => "message"
	    # target => "poi"
	    remove_field =>["message"]	   
    }
    mutate {
        remove_field => ["path","host"]             
        add_field => ["[location][lat]", "%{y}"]
        add_field => ["[location][lon]", "%{x}"]   
    } 
}


output {
    elasticsearch {
		index => "poi-003"
        hosts => ["localhost:9200"]
    }
    stdout { 
    	codec => rubydebug
    }
}

 

kibana中测试地理查询

POST poi-003/_search
{
  "query": {
    "bool": {
      "filter": {
        "geo_bounding_box": {
          "location": {
            "top_left": {
              "lat": 24.258,
              "lon": 112.254
            },
            "bottom_right": {
              "lat": 22.258,
              "lon": 114.258
            }
          }
        }
      }
    }
  }
}

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值