The discussion revolves around challenges with pagination in the Discourse API, particularly when using search/query.json to retrieve posts within a date range. danielt initially struggled with pagination, noting that page 2 and page 3 returned identical results for complex queries, unlike simpler searches. vinothkannans clarified that the query string should use & instead of ? for subsequent pages, correcting the URL structure. pfaffman shared a Ruby script for downloading topics, though it doesn’t handle date filtering. danielt acknowledged the mistake in URL formatting and questioned how to access additional posts when more_posts is true. sam confirmed pagination support and referenced the Discourse API documentation. faheem asked about the meaning of term in the API, and blake explained that term refers to a search query, not a time period, and suggested reverse-engineering the UI’s API calls to understand pagination. faheem expressed a desire to fetch all topics in a category at once, but blake clarified that multiple API calls are necessary due to performance constraints, and suggested using data explore queries as an alternative.
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?
Sto cercando di capire come utilizzare l’API di Discourse.
Nelle URL sottostanti, ipotizzo che term si riferisca a un periodo o una durata. Questo si deduce da term=after:2016-01-01%20before:2017-01-01 ecc. Ma non sono chiaro su cosa significhi term=API. Qualcuno può chiarire?
In realtà ci sono due endpoint di ricerca a cui puoi accedere: /search.json?q= e /search/query?term=
term indica semplicemente il termine di ricerca e non si riferisce a un periodo o a una durata.
Per comprendere l’API di ricerca, è meglio seguire Reverse engineer the Discourse API ed eseguire le ricerche che intendi fare tramite l’API, osservando come l’interfaccia utente effettua le stesse richieste API.
In realtà, vorrei ottenere l’intero contenuto di una pagina (nel mio caso, un elenco di argomenti in una categoria, vedi Obtaining a list of topics from a category). Non vorrei dover scorrere pagina per pagina se non è necessario. Inoltre, non credo che il reverse engineering possa funzionare in questo caso, poiché Discourse espande semplicemente la pagina mentre scorri verso il basso. Per quanto ne so, non esiste un’opzione per visualizzare l’intera pagina. Esiste un modo per farlo?
Non esiste una singola chiamata API che recuperi TUTTI i topic di una categoria. Dovrai effettuare più chiamate API. Questo perché una categoria potrebbe contenere oltre 1 milione di topic, il che potrebbe richiedere una query molto pesante e influire sulle prestazioni del tuo sito. Quando analizzi il meccanismo di scorrimento, puoi vedere come l’interfaccia utente di Discourse esegue le chiamate API per caricare altri topic, e puoi replicare questo comportamento nella tua API.
A seconda di ciò che stai cercando di ottenere, puoi anche utilizzare la query di esplorazione dati per ottenere il numero di topic in una categoria ed effettuare una chiamata API a tale query salvata.