Struggling with pagination within search/query.json

I’m trying to grab the posts within a date interval from our discourse server using the API. I’m struggling quite a lot with pagination.

Firstly I tried using search.json but that limits us to 50 results:
https://meta.discourse.org/search.json?q=after:2016-01-01%20before:2017-01-01

I tried to use the paginated query instead (but page 2 and page 3 end up the same for some queries):
https://meta.discourse.org/search/query.json?term=after:2016-01-01%20before:2017-01-01
https://meta.discourse.org/search/query.json?term=after:2016-01-01%20before:2017-01-01?page=2
https://meta.discourse.org/search/query.json?term=after:2016-01-01%20before:2017-01-01?page=3

That’s odd because simpler queries appear to paginate correctly:
https://meta.discourse.org/search/query.json?term=API
https://meta.discourse.org/search/query.json?term=API?page=2
https://meta.discourse.org/search/query.json?term=API?page=3
https://meta.discourse.org/search/query.json?term=API?page=51 (more_pages becomes null here, although we can fetch higher pages)

Is is possible to combine advanced search and pagination?

「いいね!」 1

Second (3rd, 4th, etc.,) query string should look like below. & symbol instead of ?

https://meta.discourse.org/search/query.json?term=after:2016-01-01%20before:2017-01-01&page=2
https://meta.discourse.org/search/query.json?term=API&page=2

not like this

https://meta.discourse.org/search/query.json?term=after:2016-01-01%20before:2017-01-01?page=2
https://meta.discourse.org/search/query.json?term=API?page=2

「いいね!」 3

I don’t know if it’ll help, but I wrote a little ruby program that will download all of a topic or category. (It doesn’t pay attention to dates, though.)

「いいね!」 4

Oops. Getting the links wrong is what made me believe discourse support pagination using page=X in the first place (my own bad conversion from curl to a web browser).

Perhaps I should have ask a more general question: If search/query.json has a grouped_search_result with more_posts set true, how do I get to see the additional posts?

I know this is quite late, but yes we certainly support pagination now, search for something with lots of results and then use:

How to reverse engineer the Discourse API

To find all the endpoints.

「いいね!」 3

Discourse API の使い方を理解しようとしています。
以下の URL では、term は期間や時間枠を指すのだと推測しています。これは erm=after:2016-01-01%20before:2017-01-01 などの表記に基づいています。しかし、term=API が何を指すのかは明確ではありません。どなたか解説していただけませんか?

実際には、2 つの検索エンドポイントがあります。/search.json?q=/search/query?term= です。

term は単に検索語を意味し、期間や時間には関係ありません。

検索 API を理解するには、Reverse engineer the Discourse API に従い、API を通じて行いたい検索を実行し、UI がどのように同じ API リクエストを行っているかを確認するのが最善です。

「いいね!」 1

@blake さん、こんにちは
返信ありがとうございます。

実は、ページ全体のコンテンツ(私の場合はカテゴリ内のトピック一覧、Obtaining a list of topics from a category を参照)を取得したいと考えています。可能であれば、ページを一つずつ処理したくありません。また、この場合、リバースエンジニアリングは機能しないと思います。Discourse はスクロールに応じてページを動的に展開するだけで、ページ全体を表示するオプションは私の知る限り存在しないからです。これを実現する方法はありますか?

カテゴリのすべてのトピックを取得する単一の API 呼び出しはありません。複数の API 呼び出しを行う必要があります。これは、カテゴリに 100 万件以上のトピックが含まれている可能性があり、その場合、大規模なクエリとなり、サイトのパフォーマンスに影響を与える可能性があるためです。スクロールをリバースエンジニアリングすると、Discourse UI が追加のトピックを取得するためにどのように API 呼び出しを行っているかがわかります。その動作を API で再現できます。

達成しようとしている内容によっては、カテゴリ内のトピック数を取得するためにデータエクスプローアクエリを使用し、保存されたクエリに対して API 呼び出しを行うこともできます。

「いいね!」 3