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

咨询HERE Discover API是否支持按距离对查询结果排序

Answer

Great question! Let's break this down for you:

Does the HERE Discover API support distance-based sorting?

Yes, it absolutely does! The default sorting for Discover results is based on relevance (which explains why your closest station landed in 4th place), but you can easily override this with the sort parameter.

To get results sorted by distance from your specified at coordinate (closest first), just add sort=distance to your query string. Here's your modified request example:

https://discover.search.hereapi.com/v1/discover?at=-34.0337365,151.0847004&q=station&limit=10&sort=distance&apikey=YOUR_API_KEY

This should push your nearest train station to the top of the results list immediately—no need to build a custom sorting solution from scratch.

Alternative Options

If for some edge case the sort=distance parameter doesn't behave as expected, you have a reliable fallback:

  • Each result in the API response includes a distance field (measured in meters) that represents the exact distance from your at location. You could fetch the full results and sort them client-side using this value, though this is unnecessary if the built-in sorting works (which it should for most use cases).
  • For more targeted train station searches, you could also use the HERE Places API with a category filter for train-station instead of a general q=station query. This can boost result relevance while still working with the sort=distance parameter.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.07 18:13:12