API 不支持偏移时如何从偏移中获取结果(HERE 地图 API)
How to fetch results from an offset when the API doesn't support offset (HERE Maps API)
我有一个搜索功能,可以从这里 API 的 Search endpoint. I maintain records of each search's results so I can add metadata that I need for my own purposes and also so I can provide results without always going back to HERE API. The problem I have is with paginating, specifically with providing a starting index when fetching results from HERE. Similar to how Algolia does it, I want to be able to search for a term and begin with the results at a certain index, the offset
. HERE API apparently doesn't allow this at all. The closest it comes to such a feature is that it provides the URL for the next search, as described here 获取数据。这是有限的,因为它不允许我在我指定的特定索引处开始搜索结果。所以基本上我想知道是否有一种“标准”方式来获得这种功能,即使 API.
没有提供。
我自己的解决方案
HERE API 提供了一个 size
参数,允许指定我想要的结果总数,所以我可以指定比我需要的更大的 size
,基本上使用从我想要的索引开始结果的代码。但这感觉有点老套,我想知道是否有 better/more 既定的方法来做到这一点。
乐于倾听任何想法!谢谢。 :)
Places API 本身确实不支持这种 'offset' 在特定数量的结果后开始分页。
您必须在您的应用程序中设置一个解决方法。
我有一个搜索功能,可以从这里 API 的 Search endpoint. I maintain records of each search's results so I can add metadata that I need for my own purposes and also so I can provide results without always going back to HERE API. The problem I have is with paginating, specifically with providing a starting index when fetching results from HERE. Similar to how Algolia does it, I want to be able to search for a term and begin with the results at a certain index, the offset
. HERE API apparently doesn't allow this at all. The closest it comes to such a feature is that it provides the URL for the next search, as described here 获取数据。这是有限的,因为它不允许我在我指定的特定索引处开始搜索结果。所以基本上我想知道是否有一种“标准”方式来获得这种功能,即使 API.
我自己的解决方案
HERE API 提供了一个 size
参数,允许指定我想要的结果总数,所以我可以指定比我需要的更大的 size
,基本上使用从我想要的索引开始结果的代码。但这感觉有点老套,我想知道是否有 better/more 既定的方法来做到这一点。
乐于倾听任何想法!谢谢。 :)
Places API 本身确实不支持这种 'offset' 在特定数量的结果后开始分页。 您必须在您的应用程序中设置一个解决方法。