Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google custom search api returns different total results on different pages

In the Google Custom Search API, it seems the "totalResults" field returned in the response.queries.request[0] object decreases on the last page of search results. For example, if a search comes up with 17 total results, and I send an identical request with "&start=11" appended, the value of "response.queries.request[0].totalResults" drops from 17 to 12.

I am not sure what causes this, or if its even on my end (Could Google be filtering out repeated entries after the fact?).

like image 801
visual_chefs_zach Avatar asked Sep 03 '13 13:09

visual_chefs_zach


People also ask

How do I get more than 10 results on Google API?

IF YOU ARE USING THE API Google Custom Search and Google Site Search return up to 10 results per query. If you want to display more than 10 results to the user, you can issue multiple requests (using the start=0, start=11 … parameters) and display the results on a single page.

How do I use Google Custom Search API?

Accessing Google's Custom Search JSON API requires the use of an API key. To get this key, navigate to the Custom Search JSON API page and click Get a Key. Choose an existing project, or create a new one, and click Next. Note and copy your API key.


1 Answers

It's not at your end, but an issue with Google itself. You can try the same query on Google directly and you will notice inconsistent total results towards the end of pagination. Not sure exactly why but this kind of issue is not unusual when you have a massive massive set of data to work with, processed parallelly across a massive infrastructure, and a large number of dynamic factors acting upon. Yes, could be repeated entries filtering, copyright removals etc etc.

If you are calculating your own start index then what you can do is adjust your start index if the new total result received is lower than your start index. But better to use the start index coming from the API.

like image 83
Sudeep Avatar answered Oct 02 '22 19:10

Sudeep