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?

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

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.)

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.

Я пытаюсь разобраться, как использовать API Discourse.
В приведенных ниже URL-адресах я предполагаю, что term относится к периоду или временному диапазону. Это следует из примеров вроде term=after:2016-01-01%20before:2017-01-01 и т. д. Но я не понимаю, что означает term=API. Кто-нибудь может прояснить?

На самом деле существует два поисковых эндпоинта, к которым можно обратиться: /search.json?q= и /search/query?term=.

term просто означает поисковый запрос и не относится к периоду или длительности.

Для понимания поискового API лучше всего следовать руководству по адресу Reverse engineer the Discourse API, выполнить через API те поисковые запросы, которые вы планируете использовать, и посмотреть, как интерфейс выполняет аналогичные запросы к API.

Привет @blake,
Спасибо за ответ.

На самом деле, я хочу получить полное содержимое страницы (в моём случае — список тем в категории, см. Obtaining a list of topics from a category). Мне не нужно переходить по страницам, если это не обязательно. И я не думаю, что реверс-инжиниринг здесь поможет, поскольку Discourse просто подгружает контент по мере прокрутки страницы. Насколько мне известно, нет опции для отображения всей страницы сразу. Есть ли способ это сделать?

Не существует единственного вызова API, который мог бы получить ВСЕ темы категории. Вам придется выполнить несколько вызовов API. Это связано с тем, что в категории может быть более 1 миллиона тем, и такой запрос может быть очень большим и повлиять на производительность вашего сайта. При реверс-инжиниринге прокрутки вы можете увидеть, как интерфейс Discourse выполняет вызовы API для получения дополнительных тем, и воспроизвести это поведение в вашем API.

В зависимости от того, чего вы пытаетесь достичь, вы также можете использовать запрос Data Explore для получения количества тем в категории и выполнить вызов API к этому сохраненному запросу.