Question

for a given query, google custom search api returns a json which in addition to the top N results contains the following

u'searchInformation': {u'formattedSearchTime': u'0.34',
                       u'formattedTotalResults': u'402',
                       u'searchTime': 0.335969,
                       u'totalResults': u'402'},

Can somebody explain what is the difference between formattedTotalResults and totalResults? As per my understanding, they don't account for featured ad links within the results and are always same. But I want to confirm if that's the case.

Was it helpful?

Solution

The difference is how its formatted. The first one is a numeric value the second is a string value, with formatted added.

  • searchInformation.totalResults long The total number of search results returned by the query.
  • searchInformation.formattedTotalResults string The total number of search results, formatted according to locale style.

The first one would return 1001 the second one would return 1,001 if you are in the USA and 1.001 if you where in Europe. This is because decimal and thousand separators are different in different countries around the world.

Custom-search documentation can be found here: CSE: list

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top