Get results count on the results page

4 views
Skip to first unread message

Ljuba

unread,
Jul 15, 2008, 11:05:23 AM7/15/08
to Google AJAX API
I am trying to use Google-AJAX-Search-API to plug in google search on
a web page I'm currently administrating.

Thanks to a posting in this group, I managed to set the sear
restricted to a particular site to show the results in an expanded
mode.

The page where I'm testing this is here
http://www.linguistic-typology.org/test_google.html

The search results are shown without any counts of the hits. Tthe user
does get to such counts as in the line below only if they follow the
'More results" link on the first results page
======
Results 1 - 4 of 4 from www.linguistic-typology.org for ergative.
(0.08 seconds)
=====

I am wondering if there is any way to get the results displayed
directly with the counts, as shown above. It's a rather small site so
often there will not be that many hits anyway so it would be nice to
just see how many hits there are immediately. Besides, in most cases,
the 'More results' link will be misleading. When you follow it, you do
not see more results, just the count of what you already saw. Or is
this possible in the paid version only?

Thank you in advance for your time and help.

Best wishes,
Ljuba

Ben Lisbakken

unread,
Jul 15, 2008, 12:34:25 PM7/15/08
to Google-AJAX...@googlegroups.com
Ljuba --

If you check out this FAQ:
http://code.google.com/apis/ajaxsearch/faq/#howRetrieve
You will see how to specify a callback method so that when the search returns results, you will have direct access to them in an object.  In the searcher object upon search completion, there is a value called estimatedCount.  It is what you need.  You can read about it here:
http://code.google.com/apis/ajaxsearch/documentation/reference.html#_class_GSearch
(scroll down to GSearch Properties)

Hope that helps,
Ben

Ljuba

unread,
Jul 20, 2008, 1:26:05 PM7/20/08
to Google AJAX API
Ben, thanks a lot for this!

I tried to use cursor.estimatedCount but I am very new to this, so it
is still not working.

Searching the web led me to code by Jeremy Geerdes at
http://groups.google.co.jp/group/Google-AJAX-Search-API/browse_thread/thread/a14cb278eae3699b/b73bb24310f6d3eb

where he suggests the following

function showEstResults(a,b){
if(b.cursor&&b.cursor.pages){
var c;
for(var z=0;z<this.a.length;z++){if(this.a[z].gs==b){c=this.k[z];}}
var
d=document.createElement('div'),e=b.cursor,f=parseInt(e.pages[e.currentPageIndex].start),g=f
+b.results.length,h=e.estimatedResultCount,i="Showing "+f+" - "+g+"
of"+h+" results";
d.className="gsc-resultsCounter";
d.appendChild(document.createTextNode(i));
c.K.insertBefore(d,c.K.childNodes[1]);
}

}

However, the code above did nothing for me. Where can I find more
help?

Thanks again,
Ljuba


On Jul 15, 6:34 pm, Ben Lisbakken <lisba...@google.com> wrote:
> Ljuba --
>
> If you check out this FAQ:http://code.google.com/apis/ajaxsearch/faq/#howRetrieve
> You will see how to specify a callback method so that when the search
> returns results, you will have direct access to them in an object. In the
> searcher object upon search completion, there is a value called
> estimatedCount. It is what you need. You can read about it here:http://code.google.com/apis/ajaxsearch/documentation/reference.html#_...
> (scroll down to GSearch Properties)
>
> Hope that helps,
> Ben
>
> On Tue, Jul 15, 2008 at 8:05 AM, Ljuba <ljub...@gmail.com> wrote:
>
> > I am trying to use Google-AJAX-Search-API to plug in google search on
> > a web page I'm currently administrating.
>
> > Thanks to a posting in this group, I managed to set the sear
> > restricted to a particular site to show the results in an expanded
> > mode.
>
> > The page where I'm testing this is here
> >http://www.linguistic-typology.org/test_google.html
>
> > The search results are shown without any counts of the hits. Tthe user
> > does get to such counts as in the line below only if they follow the
> > 'More results" link on the first results page
> > ======
> > Results 1 - 4 of 4 fromwww.linguistic-typology.orgfor ergative.

jgeerdes [AJAX APIs "Guru"]

unread,
Jul 20, 2008, 3:43:41 PM7/20/08
to Google AJAX API
Yeah, that code was a hack that was disabled by a later revision/
reobfuscation of the code. With your search control, all you really
need is this line of CSS:

.gsc-resultsHeader td.gsc-twiddle-opened .gsc-stats {display:inline;}

Jeremy R. Geerdes
Effective website design & development
Des Moines, IA

For more information or a project quote:
http://jgeerdes.home.mchsi.com
jgee...@mchsi.com

If you're in the Des Moines, IA, area, check out Debra Heights
Wesleyan Church!

Ljuba

unread,
Jul 22, 2008, 6:51:28 AM7/22/08
to Google AJAX API
Thanks a lot for that! Would it be possible to show me where to stick
that line though? I am sorry about this but I am really a complete
newbie here.

Ljuba

On Jul 20, 9:43 pm, "jgeerdes [AJAX APIs \"Guru\"]"
<jgeer...@mchsi.com> wrote:
> Yeah, that code was a hack that was disabled by a later revision/
> reobfuscation of the code. With your search control, all you really
> need is this line of CSS:
>
> .gsc-resultsHeader td.gsc-twiddle-opened .gsc-stats {display:inline;}
>
> Jeremy R. Geerdes
> Effective website design & development
> Des Moines, IA
>
> For more information or a project quote:http://jgeerdes.home.mchsi.com
> jgeer...@mchsi.com

jgeerdes [AJAX APIs "Guru"]

unread,
Jul 22, 2008, 1:26:08 PM7/22/08
to Google AJAX API
Well, with the page that you're editing, you'll probably have to add
this:

<style type="text/css">
.gsc-resultsHeader td.gsc-twiddle-opened .gsc-stats
{display:inline;}
</style>

You can place that in your document's head element, right after the
line reading <title>...</title>

Jeremy R. Geerdes
Effective website design & development
Des Moines, IA

For more information or a project quote:
http://jgeerdes.home.mchsi.com
jgee...@mchsi.com

Ljuba

unread,
Jul 23, 2008, 5:42:16 AM7/23/08
to Google AJAX API
Thanks again, I did place the <style type...> line in the head right
after the title but got the same results page again:

First, a results page with 'More Results' link and only after that the
usual nice google summary

======
Results 1 - 4 of 4 from www.linguistic-typology.org for ergative.
(0.08 seconds)
=====

I tryied to put the style sheet line after the script but no avail.

Any other advice and tips will be greatly appreciated.

Ljuba

On Jul 22, 7:26 pm, "jgeerdes [AJAX APIs \"Guru\"]"
<jgeer...@mchsi.com> wrote:
> Well, with the page that you're editing, you'll probably have to add
> this:
>
> <style type="text/css">
> .gsc-resultsHeader td.gsc-twiddle-opened .gsc-stats
> {display:inline;}
> </style>
>
> You can place that in your document's head element, right after the
> line reading <title>...</title>
>
> Jeremy R. Geerdes
> Effective website design & development
> Des Moines, IA
>
> For more information or a project quote:http://jgeerdes.home.mchsi.com
> jgeer...@mchsi.com

jgeerdes [AJAX APIs "Guru"]

unread,
Jul 23, 2008, 10:06:04 PM7/23/08
to Google AJAX API
Well, with the style I gave you, you're not going to see the "Results
1-4 of 4 from ..." bit. Rather, you'll see an estimated result count
in parentheses after the searcher title. With the standard search
control, that's about as good as it gets with any measure of
reliability due to the dynamic obfuscation of the API. However, you
could build your own search control that would provide these results.
In fact, if you use Firebug, you could even dissect the standard
control to utilize the same classNames, etc., so you can use the same
CSS that the API automatically loads anyway.

Jeremy R. Geerdes
Effective website design & deveopment
Des Moines, IA

For more information or a project quote:
http://jgeerdes.home.mchsi.com
jgee...@mchsi.com
Reply all
Reply to author
Forward
0 new messages