3

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?

Xerri
  • 4,916
  • 6
  • 45
  • 54

1 Answers1

4

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/">
    ...
    <Url type="application/x-suggestions+json" method="get" template="http://www.google.com/complete/search?q={searchTerms}&amp;partnerid=#YOURPARTNERID#&amp;ds=cse&output=firefox"></Url>
</OpenSearchDescription>

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

Jack Leow
  • 21,945
  • 4
  • 50
  • 55
  • Thanks for your help Jack Leow but this did not work. I tried to access the suggestions from the browser to see if that works first using the url in the "template" attribute. Here is what happened: http://www.google.com/complete/search?q=searchquery&partnerid=CUSTOM-SEARCH-ID&ds=cse&output=firefox did not generate any results but http://www.google.com/cse?cx=CUSTOM-SEARCH-ID&q=searchquery works Note that our CSE is a business edition and I post the results to our own page and also, in the xml, you have to replace '&' with '&' Thanks – Xerri Jul 28 '10 at 09:54
  • Google provided some help with the following URL : http://www.google.com/complete/search?q={searchterm}&client=partner&partnerid=000000000000000000000:xxxxxxxxxxx&ds=cse This does not support the output parameter and I might resort to creating a new intermediary page to format the results for firefox – Xerri Jul 29 '10 at 10:10
  • 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 Jul 29 '10 at 13:08
  • 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 Jul 31 '10 at 02:18
  • 2
    Does anybody knows what happened to the namespace: http://a9.com/-/spec/opensearch/1.1/ ? It's returning 404 here... – Igor Escobar Feb 26 '15 at 13:54