← Archive

Customizing web search

by Nathan Pilkenton

January 2022

Summary: I set up a simple Cloudflare Worker script to automatically redirect my web search queries based on keywords I've chosen, getting me to my destination faster and reducing the need to hunt through search results. If you just want to see the script, you can check it out here. Read on for more on why I did this.

A theory of search types

Broadly, I would categorize my web searches into two types:

Search result quality by search type

Many online have been questioning whether Google's search results have gotten worse recently.

Most of the discussion I've seen about the quality of Google's results is focused on content searches. People cite searches for things like product recommendations (which turn up a lot of ads and content marketing spam) or error messages (which can turn up those weird Stack Overflow clones) as examples of poor outcomes when using Google. In examples like these, the desired page isn't known in advance.

Here's the thing with content searches: result quality is pretty hard to measure. Sure, getting a bunch of spam links is clearly bad. But even if you get results that seem trustworthy, how do you know you've gotten the best answer to your question? Maybe there are other results out there that would have been even better—more authoritative, more comprehensive, easier to understand, etc. You don't know what you don't know.
Personally, I'm on the fence about Google's result quality for content searches; while it does seem that Google's results are lower-quality than they used to be, I still find they are typically more relevant for me than other engines' are. (Although Brave seems to get pretty close.)

On the other hand, quite a few of my searches are page searches, especially on mobile.
Some examples of the kinds of pages I am searching for: company websites, Wikipedia pages, actors or movies on IMDb, Youtube channels or specific videos, Sports Reference pages for specific players or teams, etc.

For a page search, result quality is much more objective. Since I know the exact page I'm looking for, a good search engine would make it really simple for me to find it. It's frustrating when I'm looking for a specific site and have to hunt through a list of ads and irrelevant links to get there.

And honestly, it's annoying that I have to click through at all. I'd imagine that >99% of clicks from a search for tom hanks imdb go to, you guessed it, the IMDb page for Tom Hanks. It seems like Google should be smart enough to just take me directly there.

So, if I know the exact page I'm looking for, can I get to it more efficiently?

Bangs

One answer would be to use DuckDuckGo's "bangs". These are special terms that will automatically direct your query to a particular site's search function.

Some bangs are great, like !w for searching Wikipedia. If you search tom hanks !w on DuckDuckGo, you get taken directly to his Wikipedia page. Nice!

But most aren't quite this magical.
To be clear, this isn't DuckDuckGo's fault; any shortcomings are with individual website search functions to which the bangs redirect.

For example, searching tom hanks !imdb takes me to this results page, and I'd still have to click through to get to the page I want:

The same thing happens on Youtube - here are the results for linus tech tips !yt:

It's not terrible—at least the link to the channel itself is obvious (although not quite as obvious as the 'Subscribe' button). Still, I'd prefer to get sent directly to my destination, without needing to click anything.

Feeling lucky and the '!' operator

What I'm describing is basically Google's "I'm Feeling Lucky" function, which automatically takes you to the first result for your search. For a search where I know I want the first result, this would be perfect. Unfortunately, it's not available in the omnibox or new tab page—you have to go to Google's homepage to use it.

Fortunately, DuckDuckGo has their own version of this feature (adorably called "I'm Feeling Ducky") which works with the bang !ducky, or just an exclamation point on it's own (like this: !).
DDG also has bangs that search using Google's "I'm Feeling Lucky" (either lucky or fl), but these redirect to an interstitial page that forces you to click through to actually get to the site you're looking for — sort of defeating the purpose. Here's an example.
It seems like this used to work just fine, but that Google added some sort of cross-site validation a couple of years ago that shows this redirect page for searches not made from their official button. See here for some discussion.

And searching on DuckDuckGo for tom hanks imdb ! does, in fact, get me to the right page with no extra clicks!

Lucky by nature

Okay, so I've got a solution: if I've set my default search engine to DuckDuckGo, and I'm doing a page search, and I think I can construct a query that will give me the right page as the top result, I can enter it into the omnibox and add the ! operator. I should get to my page without having to click anything.

This is good, but I wanted to push the idea a little farther. What if automatically navigating to the first result were the default?

The obvious problem would be if I wanted to make a content search, where I didn't know the page I wanted and needed to see the results. But DuckDuckGo's bangs handle this nicely: if you add both a bang like !g (for Google) and the ! operator, the bang for Google takes precedent. So if I automatically apply the ! to every search, I can still put a bang like !g in my query to get a page of search results.

Automatic redirection

I think I can do even better. My guess is that a high percentage of my content searches contain certain key words:

So ideally, I'd like a system that will show me the full search results for any query containing the trigger words highlighted above. Otherwise, it should take me directly to the first page.

To accomplish this, I wrote a simple script for a Cloudflare Worker–you can check it out here. It works like this:

  1. Parse the query from the URL
  2. Check for any bangs - if there are any, pass the query to DuckDuckGo to handle them
  3. Check for any of the words in my filter list (e.g. how, what, error, etc.) - if there are any, pass the query to Google
  4. Otherwise, append the ! operator and pass the query to DuckDuckGo

I set up a free-tier Cloudflare Worker to catch requests to a URL on a domain I control, and then changed my browser's default search engine to the same URL.

Results

Try it out! Enter a search below and see where it takes you (opens in new tab):

I've had this as my default search engine for about a month, and it's worked better than I expected. Some notes on this system:

Closing thoughts

Overall, the script is a little overkill, and the automatic filtering doesn't add that much. Going forward, I'll probably just use DuckDuckGo as my default. It's pretty easy to add the ! operator if I'm doing a page search.

In general, I'd argue a truly modern search engine would try to get users to their destination faster, bypassing the results page when possible. I'm surprised this hasn't been tried, since it seems like a perfect use case for AI, ML, "big data", etc.

To their credit, Google does seem to understand this concept. For example, if I search for tom hanks age, they show me an info box at the top of the results page to tell me he's 65 years old. This clearly helps me get the answer I'm looking for faster than if I had to look through the results (at least, assuming the info they show me is correct). In fact, the info box is way more impressive than my system above, because it works for content searches.

In the end, though, Google is heavily invested in users landing on their result pages so they can be served ads. So it's hard to imagine they would voluntarily redirect people away, even if they are clearly searching for a specific page. 


← Archive