Creating a Client-Side Search Engine With Gears

I've posted an in-depth article and tutorial on creating a client-side search engine with Gears. Here's a short snippet from the article:

Did you know that you can use Gears to do fast, client-side searching of data, similar to a client-side search engine? Gears bundles Full-Text Search (FTS) abilities right into its local, SQLite database. MySpace, for example, uses this feature with their MySpace Mail application, downloading all of a user's messages for fast, client-side search. Because all of the data is local, you can do nifty things like search over the data in real-time as the user types, something that is much harder if you have to query over the network to a server to do the searching.

Would you like to add the same kind of fast, local searching to your own web page and web applications? This article introduces you to PubTools Search and the Gears features that power it, namely Full-Text Search and Workers. PubTools Search is an open source JavaScript library that drops a client-side search engine right into your page. You configure it with basic HTML plus a list of URLs to index. Once loaded, a search form that uses the local Gears full-text search abilities will appear in your page to quickly and locally search over the documents in real time as a user types into the search field.

Please note that PubTools Search is not an official Google project or Gears API; it is a project I created on my own to teach and help developers. The Gears team does not support this project.

The article covers the following:

  • An introduction to Gears' Full-Text Search and Worker features
  • How to drop PubTools Search into your page to quickly get going
  • Deep walkthrough and dissection of how PubTools Search works internally with source code and snippets so you can use these Gears features in your own applications
  • An introduction to parts of the Dojo toolkit used in PubTools Search, using actual source from PubTools Search including a discussion on some of the techniques used in modern JavaScript development
  • Tips and tricks when working with Gears

Read the full article and try the demo yourself!

Speeding Up WordPress With Gears just recently went live with Gears support for accelerating the user-interface, and the upcoming WordPress 2.6 release will also bundle Gears.

Andrew Ozz, a member of the WordPress team and the person responsible for the Gears integration wrote the following guest post on his experience working with Gears:

I thoroughly enjoyed working with Gears. After checking the excellent API documentation and examples, the test implementation of a ManagedResourceStore in WordPress was ready to go in about an hour.

After that I only had to refine the various status messages and user prompts and the first step of implementing Gears support in WordPress was ready for public testing. That was the fastest and easiest integration with another open source software I've had the opportunity to contribute to.

Currently WordPress implements Gears support in a somewhat "non-traditional" way. It uses only the local storage to cache all static files from the admin interface on the user's computer, eliminating needless requests to the server and improving page load speed, quite significantly in some cases.

Some of the limitations of this are that Gears prompts for permission on each sub-domain, so when a user has several blogs on, it will have to be enabled for each separately. Another is that although all files are served from the local storage in SSL mode, the browser reports that the web page is partially encrypted.

The Gears support is already live on, and is included in the next version of the self-hosted WordPress, that is due in a few days.

In my opinion Gears is more than an easy way to enable online applications to work offline. It extends the web browser into an OS independent application development platform. I won't be surprised to see some very different web enabled desktop applications built with it.

Flexi-ng your muscles with Gears

When a lot of developers think about Flex, they often tie it to Flash and AIR, but you can of course integrate Flex applications with many other front-end services.

Mrinal Wadhwa has seen value in building Flex applications, and also likes functionality available in Gears.

He wrote up an article on enhancing Flex applications with Gears which had him create a sample application the uses the Desktop API in Gears.

It is interesting to take a look at the source to see how Flex applications tie back to plain old JavaScript.

For example, the following shows you how you put JavaScript into your Flex application, and then call back to the Flex code via thisMovie(APP_NAME).methodToCall:
// tells the swf if gears is installed
function isGearsInstalled() {
if ( && google.gears) { //gears is installed
//gears is not installed

function thisMovie(movieName) {
if (navigator.appName.indexOf("Microsoft") != -1) {
return window[movieName];
} else {
return document[movieName];
// ....
Thanks to Mrinal Wadhwa for taking the time to try this all out. We enjoy seeing how people take Gears into many corners of the Web!

Also, you may not have seen QuickFix, an example application that shows how you can use Flex to talk to Google App Engine. The example is created by Dick Wall from App Engine, and James Ward from Adobe.