Delivering Custom Search to your applications
September 9th, 2008 | Published in Google Custom Search
Posted by: Mark Lucovsky, Software Engineer
One of the most exciting things happening with our APIs is the clever use of Custom Search engines (CSEs), blended results, and innovative uses of UI components, resulting in rich user experiences. I'd like to highlight a few interesting applications that use the AJAX API with Custom Search, and then illustrate how Custom Search engines are accessed in the AJAX Search API. With a little effort, it is possible to get a very different search experience than the standard iframe version of CSE results to embed into your web site.
Over the last couple of weeks, users found interesting information about the U.S. elections and the party conventions at our 2008 U.S. Election page. In the center of the page, there's a page element based on the AJAX API that is designed to deliver a large amount of very specific election-related news and information in a very compact form factor. The tab labeled "Blog Posts" is simply a search on a specific CSE -- the CSE itself is simple, it covers a dozen or so well-read political blogs. This page element demonstrates the ability to deliver this in a very small form factor that's easy to place on any page. You can do a "view source" on the page and you will see what I mean. The AJAX Search API blog provides more details on how the elections page element, included below, was constructed.
Another good example is VisualDx Health. This site delivers health-related information through a very sophisticated CSE. Under the hood, it's a straightforward application that takes advantage of the underlying API. Multiple search requests are fired off in parallel to create this powerful categorized display of results. Rolling Stone takes a similar approach, but this site uses news in addition to multiple CSEs to create a segmented search experience to tailor the content to its specific audience.
Let's take a quick look at how CSEs are accessed using the AJAX Search API.
Check the responses -- it's pretty easy. If you prefer using JavaScript objects, something like this also works:
The AJAX API team is working to deliver Google services through a RESTful JSON/JSON-P based system, as well as the large collection of JavaScript classes and high level page elements that developers use to build these very clever sites. The combination of the AJAX APIs and CSEs is a pretty powerful system. Learn more by reviewing our documentation and posting questions/suggestions on our developer forum.
One of the most exciting things happening with our APIs is the clever use of Custom Search engines (CSEs), blended results, and innovative uses of UI components, resulting in rich user experiences. I'd like to highlight a few interesting applications that use the AJAX API with Custom Search, and then illustrate how Custom Search engines are accessed in the AJAX Search API. With a little effort, it is possible to get a very different search experience than the standard iframe version of CSE results to embed into your web site.
Over the last couple of weeks, users found interesting information about the U.S. elections and the party conventions at our 2008 U.S. Election page. In the center of the page, there's a page element based on the AJAX API that is designed to deliver a large amount of very specific election-related news and information in a very compact form factor. The tab labeled "Blog Posts" is simply a search on a specific CSE -- the CSE itself is simple, it covers a dozen or so well-read political blogs. This page element demonstrates the ability to deliver this in a very small form factor that's easy to place on any page. You can do a "view source" on the page and you will see what I mean. The AJAX Search API blog provides more details on how the elections page element, included below, was constructed.
Another good example is VisualDx Health. This site delivers health-related information through a very sophisticated CSE. Under the hood, it's a straightforward application that takes advantage of the underlying API. Multiple search requests are fired off in parallel to create this powerful categorized display of results. Rolling Stone takes a similar approach, but this site uses news in addition to multiple CSEs to create a segmented search experience to tailor the content to its specific audience.
Let's take a quick look at how CSEs are accessed using the AJAX Search API.
- Take a plain old web search URL like this
-
- http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=barack%20obama
- Add a new CGI arg called &cx to refer to an existing custom search engine
-
- http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=barack%20obama&cx=010222979794876194725:pqldevwuapa
Check the responses -- it's pretty easy. If you prefer using JavaScript objects, something like this also works:
var search = new google.search.WebSearch();You can dig deeper to view how these applications are built. Using Firebug, you can also take a look at the "Net" tab to focus on the JS request/response stream while performing searches.
search.setSiteRestriction("010222979794876194725:pqldevwuapa");
search.execute("barack obama");
The AJAX API team is working to deliver Google services through a RESTful JSON/JSON-P based system, as well as the large collection of JavaScript classes and high level page elements that developers use to build these very clever sites. The combination of the AJAX APIs and CSEs is a pretty powerful system. Learn more by reviewing our documentation and posting questions/suggestions on our developer forum.