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.

Estoy tratando de entender cómo usar la API de Discourse.
En las URLs a continuación, supongo que term se refiere a un período o duración. Esto se basa en term=after:2016-01-01%20before:2017-01-01, etc. Pero no tengo claro a qué se refiere term=API. ¿Alguien puede aclararlo?

En realidad, hay dos puntos finales de búsqueda a los que puedes acceder: /search.json?q= y /search/query?term=.

term simplemente significa término de búsqueda y no se refiere a un período o duración.

Para comprender la API de búsqueda, lo mejor es seguir Reverse engineer the Discourse API y realizar las búsquedas que planeas hacer mediante la API, observando cómo la interfaz de usuario realiza las mismas solicitudes a la API.

Hola @blake,
Gracias por la respuesta.

En realidad, me gustaría obtener todo el contenido de una página (en mi caso, una lista de temas en una categoría, ver Obtaining a list of topics from a category). No quiero ir página por página si no es necesario. Y no creo que la ingeniería inversa funcione en este caso, porque Discourse simplemente expande la página a medida que haces scroll hacia abajo. No conozco ninguna opción para mostrar toda la página de una vez. ¿Existe alguna manera de hacer esto?

No existe una única llamada a la API que recupere TODOS los temas de una categoría. Tendrás que realizar múltiples llamadas a la API. Esto se debe a que una categoría podría tener más de 1 millón de temas, lo que podría constituir una consulta enorme y afectar el rendimiento de tu sitio. Al realizar ingeniería inversa del desplazamiento, puedes observar cómo la interfaz de usuario de Discourse realiza las llamadas a la API para obtener más temas, y puedes replicar ese comportamiento en tu API.

Dependiendo de lo que intentes lograr, también puedes utilizar la consulta de exploración de datos para obtener el número de temas en una categoría y hacer una llamada a la API a esa consulta guardada.