I wanted to issue a warning, as well as a question if anyone has the
answer. *cough* Jeremy *cough* :P

.estimatedResultCount seems to be unpredictable at best, and downright
counter-productive at worst. As you use .gotoPage() the value
of .estimatedResultCount seems to fluctuate rampantly, and can mislead
your application's navigation through pages.

For example, certain terms I searched on, return values as high as
70s, but then when I tried to call gotoPage(8) (which should contain
results 56-64) the cursor object suddenly realized that there were
actually more like 30 results. So if anyone knows why this occurs I
would be curious, but in the meantime I wrote a function to calculate
this value manual which is vastly more accurate.

/******************************************************************
 * This function gets the total number of results for the search.
 * It takes a Searcher object as a parameter and returns the total
 *****************************************************************/

function getTotalResults(cs){
   // Set a handle to the cursor object that we're going to use
repeatedly
   var cursor = cs.cursor;
   var total = 0;
   //8 results per page (assuming LARGE_RESULTSET)
   total = ((cursor.pages.length - 1)*8);
   //if it's appropriate, go to the last page and count the results
there.
   if (cursor && cursor.pages.length>cursor.currentPageIndex+1)
{cs.gotoPage(cursor.pages.length - 1);}
   total = total + cs.results.length;
        return total;
}

Thanks guys.

ben
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google AJAX APIs" group.
To post to this group, send email to Google-AJAX-Search-API@googlegroups.com
To unsubscribe from this group, send email to 
google-ajax-search-api+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-AJAX-Search-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to