You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在ElasticSearch中连接同一船舶的轨迹点

解决船舶轨迹连线问题

核心问题:字段不匹配

你提供的映射里用了my_location、group、@timestamp,但实际数据字段是Location、ShipId、Timestamp,字段名不对应导致geo-line聚合无效。

步骤1:修正索引映射

确保你的索引映射和实际字段匹配,ShipId必须设为keyword类型(用于分组),Timestamp设为date类型:

{
    "mappings": {
        "properties": {
            "Location": { "type": "geo_point" },
            "ShipId": { "type": "keyword" },
            "Timestamp": { "type": "date" },
            "SpeedOverGround": { "type": "integer" },
            "ShipName": { "type": "keyword" }
        }
    }
}

注意:如果索引已创建,需要重新创建索引并重新导入数据(现有映射无法直接修改),或者使用reindex API调整映射。

步骤2:执行geo-line聚合查询

用以下查询按ShipId分组,生成每条船舶的轨迹线:

{
    "size": 0,
    "aggs": {
        "ships": {
            "terms": {
                "field": "ShipId",
                "size": 100  // 按需调整展示的船舶数量
            },
            "aggs": {
                "track": {
                    "geo_line": {
                        "point": {
                            "field": "Location"
                        },
                        "sort": {
                            "field": "Timestamp"
                        },
                        "size": 1000  // 单条船舶最多展示的轨迹点数量
                    }
                }
            }
        }
    }
}

步骤3:在Kibana地图中展示轨迹

  1. 创建包含船舶索引的数据视图
  2. 新建地图可视化,选择聚合图层
  3. 聚合类型选择Geo Line
  4. 分组字段选择ShipId(keyword类型)
  5. 排序字段选择Timestamp,设置为升序(按时间顺序连接轨迹点)
  6. 位置字段选择Location(geo_point类型)
  7. 调整时间范围为你的1小时数据区间,即可看到每条船舶的轨迹连线

内容的提问来源于stack exchange,提问作者Karthik Garimella

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.25 01:11:01