开发者

Google Custom Search and Opensearch

I have a Google Custom Search Engine on our site and I have recently implemented the opensearch XML file so that I can ad开发者_运维技巧d our site's search in the browsers' search box.

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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜