Discourses API get just the number of search results

Discourse API gem 使用的是 /search/query 路由。它似乎不支持分页。而 Discourse UI 使用的是 /search 路由,它支持分页。

你可以在浏览器中测试这一点:访问 http://forum.example.com/search.json?q=test,然后尝试 http://forum.example.com/search.json?q=test&page=2。

你可能需要找到一种不使用 Discourse API gem 的方式来调用 API。如果你的目标是获取站点上的所有主题和帖子,使用 /search 路由似乎并不是最佳方案。

你可以尝试调用 http://forum.example.com/c/your-category-slug.json。如果该请求未返回类别中的所有主题,则响应的 topic_list 中将包含一个 more_topics_url 属性,该属性会提供下一页主题的链接,例如 "/c/site-feedback?page=2"。你需要在 URL 后添加 .json 以获取 JSON 数据(例如 /c/site-feedback.json?page=2)。