Performing Proximity Searches

GAPS performs a proximity check between two words.

There are some times when it would be advantageous to search both forward and backward. For example, if you’re doing genealogy research, you might find your uncle John Smith as both John Smith or Smith John. Similarly, some pages might include John’s middle name—John Q Smith or Smith John Q.

Tip

If all you’re after is query permutations, the Permute hack [Hack #62] might do the trick.

You might also need to find concepts that exist near each other but aren’t a phrase. For example, you might want to learn about keeping squirrels out of your bird feeder. Various attempts to create a phrase based on this idea might not work, but just searching for several words might not find specific enough results.

GAPS, created by Kevin Shay, allows you to run searches both forward and backward and within a certain number of spaces of each other. GAPS stands for “Google API Proximity Search,” and that’s exactly what this application is: a way to search for topics within a few words of each other without having to run several queries in a row. The program runs the queries and organizes the results automatically.

You enter two terms (there is an option to add more terms that will not be searched for proximity) and specify how far apart you want them (1, 2, or 3 words). You can specify that the words be found only in the order you request (wordA, wordB) or in either order (wordA, wordB, and wordB, wordA). ...

Get Google Hacks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.