Service available for Google Suggest?

37 views
Skip to first unread message

Loc Tan Vo

unread,
Sep 11, 2009, 5:32:17 AM9/11/09
to Google Search Appliance/Google Mini - Google Search Appliance/Google Mini
Hi all,

I'm looking into the new feature in Search Appliance called Google
Suggest. I'm aware of the fact that it's still in Beta.

I've been reading the documentation:
http://code.google.com/apis/searchappliance/documentation/60/admin_searchexp/ce_improving_search.html#querysugg
http://code.google.com/apis/searchappliance/documentation/60/NewFeatures60.html#UpdatingSS

and I'm wondering if there is a service available that provides the
list of suggestions?

We are not using the UI provided with the box, but parsing the XML
results ourselves. The documentation provided on Google Suggest
feature is all about how to enable it in the default UI. Without
knowing the details behind the implementation, I guess it's a
combination of javascript doing ajax requests to a service running on
the box somehow. If there actually is a service, is there any
documentation available?

Best regards,
Loc

Mahesh T

unread,
Sep 11, 2009, 7:04:56 AM9/11/09
to Google Search Appliance/Google Mini - Google Search Appliance/Google Mini
Hi,

http://<GSA IP or HOST NAME>/suggest?token=<USER TYPED CHARACTERS
HERE>&max_matches=10&use_similar=0

eg: http://127.0.0.1/suggest?token=hi&max_matches=10&use_similar=0

Soon I will create a page on this group on how I managed to enable GSA
suggest on a custom form.

Mahesh

Loc Tan Vo

unread,
Sep 11, 2009, 9:20:07 AM9/11/09
to Google Search Appliance/Google Mini - Google Search Appliance/Google Mini
Thanks Mahesh!

Exactly what I was looking for. I managed to find the "/suggest" page,
but didn't quite manage to figure out the query parameters yet. Your
answer saved me lots of work.

Thanks a lot.

Loc

Mahesh T

unread,
Sep 16, 2009, 7:27:52 AM9/16/09
to Google Search Appliance/Google Mini - Google Search Appliance/Google Mini

Loc Tan Vo

unread,
Sep 16, 2009, 8:02:56 AM9/16/09
to Google Search Appliance/Google Mini - Google Search Appliance/Google Mini
Nice! Thanks for notifying.

Loc

On Sep 16, 1:27 pm, Mahesh T <lightbe...@gmail.com> wrote:
> The documentation is updated recently on Query suggestion service -
>
> http://code.google.com/apis/searchappliance/documentation/60/xml_refe...

abc

unread,
Sep 16, 2009, 5:25:26 PM9/16/09
to Google Search Appliance/Google Mini - Google Search Appliance/Google Mini
Hi all,

I've added <xsl:variable name="show_suggest">1</xsl:variable> to my
front end XSLT, as suggested by documentation, at:

http://code.google.com/apis/searchappliance/documentation/60/xml_reference.html#QuerySuggestionsSuggestURLParameter

My GSA neatly delivers results when requested as follows:

http://127.0.01/suggest?token=wat&max_matches=10

The problem is, nothing is said in the documentation about the code
needed on the client side. Could you provide a more detailed
instruction? What AJAX code is involved?

Any help would be appreciated

Loc Tan Vo

unread,
Sep 17, 2009, 4:40:19 AM9/17/09
to Google Search Appliance/Google Mini - Google Search Appliance/Google Mini
Hi abc,

With the default search interface, or XSL, there already is a
javascript file included that does the clientside autocompletion/
suggestion you are searching. Please have a look here on how to enable
it:

http://code.google.com/apis/searchappliance/documentation/60/admin_searchexp/ce_improving_search.html#querysugg

If this is not what you are looking for, I assume you are integrating
with the Google box through XML communication. In this case you would
be interested in the service at /suggest (as you already have tried
out). In this case you need to implement the Ajax communication
yourself, as the google box only returns suggestions based on tokens
you provide. How you want to implement the client side communication
is up to you. An option is to have a look at the javascript that
already does this in the Google box (a javascript file available at
http://<your search appliance address>/suggest_js.js). However, this
javascript file is minized and optimized and it not so easy to read.

Since I'm not sure how much experience you have with Ajax development,
I'll try to describe things stepwise. Please don't be offended if it
turns out that I've totally misunderstood your question and my answer
is too fine-grained.

I assume the following setup on your infrastructure:

1. You have a search user interface at e.g. http://yourDomain.com/search/
2. Further, you have the GSA box running at http://ipAddressToGsaBox/
3. The communication from your web server at yourDomain.com and the
GSA box is based on Http for querying, and parsing of the Xml results.
4. You now want to implement client side logic so the user interface
at http://yourDomain.com/search/ will show suggestions when the user
start typing in a search box.

So this is conceptually what you have to do (assuming you are using
Javascript to do your Ajax communication):

1. Add an event on the search box that fires off every time a user
type a letter.
2. Whenever an event fires off, you collect the letters the user has
typed in the text box.
3. You use these letters, and you construct and send an Ajax request
to get back a list of suggestions.
4. You display the suggestions for the user.

This is the general idea without detailed information on how to
implement this. An important comment on point 4: due to browser
security, Ajax requests are normally restricted to the domain the
javascript comes from, which means that you can't do Ajax requests
wherever you want to. If your web server and your google box don't
have the same domain, you have to work around this issue. A normal
approach is to create some sort of proxy on your web server that
communicates with the Google box when an Ajax request comes in. This
is what I normally do. There are other techniques as well that you
might want to check out.

I have great experience using jQuery (javascript library) to do my
Ajax communication and other overall javascript functionalities. There
already are plugins that handles autocompletion really well; you
basically just have to provide where it could fetch the list of
suggestions. You might well want to have a look at these solutions.

Lastly, I just want to say that I'm neither a GSA expert, nor a
Javascript/AJAX expert. My suggestion is one of many possible
solutions, and of course not necessarily the optimal in your case.
Please do not hesitate to ask if things seem unclear. If you have more
concrete questions, I'm happy to try to help.

Cheers,
Loc


On Sep 16, 11:25 pm, abc <vpo...@unl.edu> wrote:
> Hi all,
>
> I've added <xsl:variable name="show_suggest">1</xsl:variable> to my
> front end XSLT, as suggested by documentation, at:
>
> http://code.google.com/apis/searchappliance/documentation/60/xml_refe...

abc

unread,
Sep 17, 2009, 12:26:32 PM9/17/09
to Google Search Appliance/Google Mini - Google Search Appliance/Google Mini
Hello, Lock!

First off, thank you very much for your abundant goodwill. You
provided me with so much information that I'm not able to absorb all
of it. Since there are things I'm not sure I fully understood, and
since I'd like you to be sure you understand what my needs might be, I
owe you a detailed presentation of my current search solution and
environment.

All my web sites' pages contain a search box with the following code:

<script>var aa = location.host;</script>
<form method="GET" action="search.shtml" onSubmit="this.q.value +=
'+site:'+aa;">
<input type="text" name="q" size="15" maxlength="256" value="">
<input type="hidden" name="client" value="default_frontend">
<input type="hidden" name="site" value="default_collection">
... other parameters here ...
</form>

Each web site names its own search page, in the case above targeted
search page is search.shtml. Search pages submit requests to a
wrapper, sitting on a separate server, as follows:

<script>

whoasked = location.hostname + location.pathname;

document.write("<script type='text/javascript' +
src='http://wrapperhost.unl.edu/wrapper.cgi' +
location.search + '&whoasked=' + a +
'</script>'");
</script>

As could be inferred from the explanation above, wrapper.cgi submits
requests to GSA, fetches the result set delivered by GSA in the
default front end page, parses the page to extract only the
'meat' (web scraping) and, finally, delivers it back to the web site's
requesting search page in the form of javascript document.write
instruction. To see it in action, please go to beef.unl.edu, or
cropwatch.unl.edu, or agalmanac.unl.edu and search for 'summer', for
instance, since it would render some results in all three cases.

Now, the basic question is whether AJAX can be applied in such an
environment? Can my clients directly communicate with GSA 'suggest'
service (I suppose yes), considering that there is an intermediate
program, sitting on an intermediate server, between clients and GSA?
True, they are all in the same domain unl.edu, but still...

One more detail: I've imported a copy of my GSA config file for
version 5.0.0.G32-P1 which does not contain javascript code for
suggest option, but I'll copy it from front end version 6.0.

I never did AJAX, but I'll learn it, of course. Google Suggest
functionality is well worth it.

In the end, my apologies for being overly demanding, and my many
thanks for your patience.

Cheers!


On Sep 17, 3:40 am, Loc Tan Vo <loc.tan...@gmail.com> wrote:
> Hi abc,
>
> With the default search interface, or XSL, there already is a
> javascript file included that does the clientside autocompletion/
> suggestion you are searching. Please have a look here on how to enable
> it:
>
> http://code.google.com/apis/searchappliance/documentation/60/admin_se...
>
> If this is not what you are looking for, I assume you are integrating
> with the Google box through XML communication. In this case you would
> be interested in the service at /suggest (as you already have tried
> out). In this case you need to implement the Ajax communication
> yourself, as the google box only returns suggestions based on tokens
> you provide. How you want to implement the client side communication
> is up to you. An option is to have a look at the javascript that
> already does this in the Google box (a javascript file available at
> http://<your search appliance address>/suggest_js.js). However, this
> javascript file is minized and optimized and it not so easy to read.
>
> Since I'm not sure how much experience you have with Ajax development,
> I'll try to describe things stepwise. Please don't be offended if it
> turns out that I've totally misunderstood your question and my answer
> is too fine-grained.
>
> I assume the following setup on your infrastructure:
>
> 1. You have a search user interface at e.g.http://yourDomain.com/search/
> 2. Further, you have the GSA box running athttp://ipAddressToGsaBox/
> 3. The communication from your web server at yourDomain.com and the
> GSA box is based on Http for querying, and parsing of the Xml results.
> 4. You now want to implement client side logic so the user interface
> athttp://yourDomain.com/search/will show suggestions when the user
> > Any help would be appreciated- Hide quoted text -
>
> - Show quoted text -

Merri

unread,
Sep 17, 2009, 5:56:31 PM9/17/09
to Google Search Appliance/Google Mini - Google Search Appliance/Google Mini
I have explored the technote at the following link (found by
'googling' google search appliance /suggest)

http://www.mcplusa.com/blog/2009/07/adding-google-search-appliance-suggest-search-to-your-existing-page/

And have followed the steps and have the suggestions working through
the proxy, but they still seem to come back in json format ie;
["word1","word 2","word 3","etc"]

am not able to get the styles or ajax to fire into a drop down box.
can anybody post a simple Asp example? most of our searches are
conducted remotely from our intranet server.

As the link above suggests, I have copied the suggest_js.js to my
local webserver, edited it to point to the gsa, then made this page.
can anybody tell me what is missing? I get JSON results - if i hit
enter........

================
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://
www.w3.org/TR/html4/loose.dtd">
<html>
<head>


<script language='javascript' src='suggest_js.js'></script>
<script language='javascript'>
sgst('q');
sgst('token'); </script>

<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">

<style>
.ac-renderer {
position: absolute
width : 300px;
background-color : #cccccc;
border : 1px solid #999;
}
.ac-row {
position : relative;
background-color : #cccccc;
margin : 1px;
padding : 1px 4px;
cursor : pointer;
}
.ac-highlighted {
color : #111;
}
.ac-active {
background-color : #cccccc;
color : #111;
font : bold;
}
--></style>
</head>

<body >

<form name="form1" method="post" action="">
<input type="text" name="token"> ' I really don't know what to do
to make this fire, if i hit enter, I get results
</form>

<%dim srcFile
srcFile = "http://mygsa/suggest?token=" & Request("token") &
"&max_matches=10"
'Get the JSON
Response.Buffer = True
Dim objXMLHTTP, xml


'Create an xmlhttp object
Set xml = Server.CreateObject("Microsoft.XMLHTTP")


xml.Open "GET", srcfile , False
xml.Send


Response.Write xml.responseText
set xml= Nothing%>
</body>
</html>









======
> > athttp://yourDomain.com/search/willshow suggestions when the user
> > - Show quoted text -- Hide quoted text -

abc

unread,
Sep 17, 2009, 10:02:29 PM9/17/09
to Google Search Appliance/Google Mini - Google Search Appliance/Google Mini
Merri,

I've found the following tutorial very useful:

http://www.dynamicajax.com/fr/AJAX_Suggest_Tutorial-.html

The guy created his own search suggest similar to Google Suggest. He
uses javascript and PHP, but it helped me understand how onkeyup event
handler fetches suggestions from the proxy and how the drop down list
with suggestions is generated - basically, it helped me understand the
underlying logic of the search suggest functionality.

HTH


On Sep 17, 4:56 pm, Merri <mfurl...@sandc.com> wrote:
> I have explored the technote at the following link (found by
> 'googling' google search appliance /suggest)
>
> http://www.mcplusa.com/blog/2009/07/adding-google-search-appliance-su...
> > > athttp://yourDomain.com/search/willshowsuggestions when the user

abc

unread,
Sep 17, 2009, 10:14:41 PM9/17/09
to Google Search Appliance/Google Mini - Google Search Appliance/Google Mini
Lock,

I believe you can disregard my previous post since, after tinkering
with AJAX, I realise why proxy is needed and what it's supposed to do.

Problem is, my GSA and accompanying wrapper serve about three hundred
web sites, hosted by more than a dozen multy-hosting servers, which
means that almost all web sites are set up as virtual servers,
therefore, as descrete domains.

In such an environment it wouldn't be very practical to have a proxy
for each and every web site, sitting in their respective web space -
it wouldn't even be possible since I don't have control over some of
the web servers. Now I realise I need a cross-domain solution without
proxies involved - and now I understand what you were talking
about! :-)

Thank you very much for all your help.


On Sep 17, 11:26 am, abc <vpo...@unl.edu> wrote:
> > athttp://yourDomain.com/search/willshow suggestions when the user
> > - Show quoted text -- Hide quoted text -

Merri

unread,
Sep 30, 2009, 11:27:54 AM9/30/09
to Google Search Appliance/Google Mini - Google Search Appliance/Google Mini
Thanks, I used your tutorial and the mcplusa technote to come up with
the following three files, which can be put on an IIS/asp intranet
webserver.
basically uses a proxy page for the gsa, then xml's the xml

=============contents of sample form ============


<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://
www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<style>

-->
.suggest_link {
background-color: #FFFFFF;
padding: 2px 6px 2px 6px;
}
.suggest_link_over {
background-color: #3366CC;
padding: 2px 6px 2px 6px;
}
#search_suggest {
position: absolute;
background-color: #FFFFFF;
text-align: left;
border: 1px solid #000000;
margin-top: -20px;
}
</style>



<script language="javascript" src="http://intranet/suggest_js.js"></
script>
<script language="javascript">

function OnSubmitForm()
{
document.f.action ="http://gsa/search";

}

function getXmlHttpRequestObject() {
if (window.XMLHttpRequest) {
return new XMLHttpRequest();
} else if(window.ActiveXObject) {
return new ActiveXObject("Microsoft.XMLHTTP");
} else {
alert("upgradethatbrowser");
}
}

//Our XmlHttpRequest object to get the auto suggest
var searchReq = getXmlHttpRequestObject();



function searchSuggest()
{ if (searchReq.readyState == 4 || searchReq.readyState == 0)
{ var str = escape(document.getElementById('q').value);
searchReq.open("GET", 'http://intranet/proxy.asp?token=' + str,
true);
searchReq.onreadystatechange = handleSearchSuggest;
searchReq.send(null); } }

function handleSearchSuggest()
{ if (searchReq.readyState == 4)
{ var ss = document.getElementById('search_suggest')
ss.innerHTML = '';
var str = searchReq.responseText.split(",");
for(i=0; i < str.length - 1; i++)
{ var suggest = '<div onmouseover="javascript:suggestOver
(this);" ';
suggest += 'onmouseout="javascript:suggestOut(this);" ';
suggest += 'onclick="javascript:setSearch(this.innerHTML);" ';
suggest += 'class="suggest_link">' + str[i] + '</div>';
ss.innerHTML += suggest; } }}

//Mouse over function
function suggestOver(div_value) {
div_value.className = 'suggest_link_over';
}
//Mouse out function
function suggestOut(div_value) {
div_value.className = 'suggest_link';
}
//Click function
function setSearch(value) {
document.getElementById('q').value = value;
document.getElementById('search_suggest').innerHTML = '';
}

</script>

<title>test</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">

</head>

<body >

<form name="f" method="get" action="" >
<input type="text" name="q" OnKeyUp="searchSuggest('q')";>



<input type="submit" name="search" value="search" onclick="return
OnSubmitForm();">


<input type="hidden" name="entqr" value="3">
<input type="hidden" name="entsp" value="a">
<input type="hidden" name="site" value="default_collection">
<input type="hidden" name="ud" value="1">
<input type="hidden" name="sort" value="date:D:L:d1">
<input type="hidden" name="output" value="xml_no_dtd">
<input type="hidden" name="oe" value="UTF-8">
<input type="hidden" name="ie" value="UTF-8">
<input type="hidden" name="client" value="default_frontend">
<input type="hidden" name="proxystylesheet"
value="default_frontend">

</form>
<div id="search_suggest"></div>

</body>
</html>

==========contents of suggest_js.js=======================
download the http://gsa/suggest_js and put it on your intranet
find ("/suggest') and replace with ("HTTP://intranet/proxy.asp")

============contents of proxy.asp===================================

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://
www.w3.org/TR/html4/loose.dtd">
<%dim srcFile
srcFile = "http://gsa/suggest?token=" & Request.querystring("q") &
Request.querystring("token") & "&max_matches=10"
'Get the JSON
Response.Buffer = True
Dim objXMLHTTP, xml


'Create an xmlhttp object
Set xml = Server.CreateObject("Microsoft.XMLHTTP")
xml.Open "GET", srcfile , False
xml.Send
Response.Write replace(replace(replace(xml.responseText,"[",""),chr
(34),""),"]","")
'Response.Write xml.responseText

set xml= Nothing%>

<script language="javascript" src="http://intranet/suggest_js.js"></
script>

Mahesh T

unread,
Oct 7, 2009, 6:28:07 AM10/7/09
to Google Search Appliance/Google Mini - Google Search Appliance/Google Mini
Check the below page on this group--
http://groups.google.com/group/google-search-appliance/web/gsa-query-suggestions-on-a-custom-page?hl=en


PS: Hope someone can find this (duplicate) post while searching on
this group.

Michael Cizmar

unread,
Oct 8, 2009, 7:04:38 PM10/8/09
to Google Search Appliance/Google Mini - Google Search Appliance/Google Mini
Great job Mahesh!

Michael Cizmar | MC+A
Google Enterprise Partner
www.mcplusa.com | twitter: http://www.twitter.com/mcplusa

On Oct 7, 5:28 am, Mahesh T <lightbe...@gmail.com> wrote:
> Check the below page on this group--http://groups.google.com/group/google-search-appliance/web/gsa-query-...
Reply all
Reply to author
Forward
0 new messages