Reputation: 33
I'm making a twitter corpus of my own. I've exposed the querying of the twitter corpus as a REST API using Java Servlets. However, when I do a search using the REST API all the results (>1000) are returned in one HTTP response and it takes a while to download.
I am planning to add pagination to the search like the Twitter API. For example,
http://search.twitter.com/search.json?q=blue%20angels&page=1&rpp=50
http://search.twitter.com/search.json?q=blue%20angels&page=2&rpp=50
Here rpp is results per page. So in request 1 you can the first 50 results, request fetches the next page with 50 results.
Any suggestions on how this can be done in Java servlets? Right now its very slow since the HTTP response gets huge..
Upvotes: 3
Views: 4620
Reputation: 11256
Obviously make page and rpp parameters, and receive them in your servlet.
Then you need to use these values to efficiently query the underlying database. The pagination SQL syntax might differ from DB to DB.
For MySQL, for instace, doing efficient pagination is explined here.
Upvotes: 1