views:

33

answers:

1

I have a Google Custom Search Engine on our site and I have recently implemented the opensearch XML file so that I can add our site's search in the browsers' search box.

Any idea how I can add the autocomplete / suggestion feature to the browsers' search box?

+1  A: 

I'm assuming you've already enabled "autocompletions" on your Google CSE search engine configuration.

The next step is to add a Url element with the type "application/x-suggestions+json" in the OpenSearchDescription element. I looked into this a little, and the following URL seems like it should work (be sure to enter your own partnerid where it says [YOUR PARTNER ID]:

http://www.google.com/complete/search?q={searchTerms}&partnerid=`[YOUR PARTNER ID]`&ds=cse&output=firefox

e.g.,

<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/"&gt;
    ...
    <Url type="application/x-suggestions+json" method="get" template="http://www.google.com/complete/search?q={searchTerms}&amp;amp;partnerid=#YOURPARTNERID#&amp;amp;ds=cse&amp;output=firefox"&gt;&lt;/Url&gt;
</OpenSearchDescription>

Here's a little webapp I created (pre-populated with some helpful values) to help you with your OSDD.

Jack Leow
thearchitect
thearchitect
That's an option. Sorry about my lack of response, I created a Custom Search Engine account, and enabled autocomplete, but am still waiting for the autocomplete feature to be activated.
Jack Leow
My autocomplete list finally got populated, and I think you're right, you're going to need to create a proxy/intermediary page to strip out the callback function. I can't get Google to generate the search suggestions list without a callback function.
Jack Leow