Why doesn't Google web search work?

(I asked and answered this question elsewhere on my site, before creating the Question Bank. I'll repeat it here in the Bank for completeness.)

Recap

As described earlier, I've placed many a Google web search block into Drupal sites, using Google AdSense for Search.

https://www.google.com/adsense/search-settings

All to a single end: the blocks don't work. (Hey, consistency counts for something, right?)

As I detailed, both Google and Drupal (even with clean URLs implemented) want to use q in the search parameters toward conflicting ends, resulting in goofiness. One suggested solution is to replace the problematic q in the search code with as_q, something Google and Drupal will both accept but not fight over. (Saintly correspondent jGirlyGirl informs me that query works as well.)

Alas, my problems only half-disappeared: with the code tweak, on-site searches worked fine, but web searches would only return "Your search... did not match any documents."

Hacking...

I hacked much yesterday, trying all sorts of little tweaks to the search code. I then came up with the brilliant strategy I should have thought of weeks ago, which was to check out some sites with working Google search blocks. I even hit upon the perfect candidate: the excellicious 43 Folders site by burgeoning Internet hero Merlin Mann.

http://www.43folders.com

That site not only employs an AdSense for Search block for both on-site and web searches, but it's a Drupal site as well! (Let 43 Folders, not The Onion, be our new poster child for Drupal sites.)

With that specimen laid out before me, I sought to employ the single most valuable technique known to me as a programmer. That's right: copying other people's code.

I viewed the source code for 43 Folders' search results page, and compared with my own. Hmm, 43 keeps the unadorned q in its search parameters; apparently, Merlin solved that problem at the .htaccess level or elsewhere. Yet as_q should still work for me, as it has for many others. I see, too, that 43's code specifies its search results page with a trailing "/", while my code does not. Was that the problem? No, tacking a slash onto the end of the page URL in my code didn't fix things (in action, the slash just gets stripped out of the resulting URL anyway).

And so on. I noted every difference I could find. I even went as far as nabbing 43's search code wholesale and pasting it into my Drupalace search block, changing only the obvious particulars like my domain, my search result page URL, etc. But every variation I tried resulted in some error: either a "Your search... did not match any documents" result or a "page not found" result, for on-site search, web search, or both.

"Why will this same code work for him, but not for me? Aaaarrgggghhh!!!!"

Average: 5 (1 vote)

Trackback URL for this post:

http://www.drupalace.com/trackback/58

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd><br><p>
  • You may quote other posts using [quote] tags.
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

CAPTCHA
Sorry for the "captcha" spam-detector challenge; the spammers have been out in force. : (
scholars_ip: