cc licensed flickr photo shared by Stéfan

That little search field and button in WordPress has not changed in function one bit since i started with WordPress. Oh sure, you can pop words in there, and get list of results. That works. But it is really limiting, especially when you have a few years heaped up of posts.

Let me be more specific. If I want to find something I wrote about Jim Groom and car toys, if I type in the search field

Jim Groom Car Toys

My results will include posts that mention Jim Morrison, ones about Jim beam, Ones about not wanting to be a bride of a groom, ones about Dean Groom, onces about Car Shows, ones about Toys are us, and maybe after I page through 5 pages of results, I might find the one I want.

You see, the WordPress search is all OR. It matches “Jim” OR “Groom” OR “Car” OR “Toys”. And… the results are not in relevance order, I get reverse chronology, which does not help me at all in finding.

That is like Search 0.5, back in te days of AltaVista.

If I was searching in Google, I’d be smarter, and do a search like:

“Jim Groom” Car +Toys

So I get an exact match on the name, and force the results to have Toys in it (I may be less sure it had “Car” or “Truck”.

I did some quick poking at the WordPress Plugins and did not find too many search enhancements– I thought there would be a good set of them. I found ones that expand the search to include pages, tags, etc.

But then I found the Google Custom Search plugin. Now GSE is one of the lesser used, less understood powerful tools in the Google jet pack. The premise is simple- you can create your own search tools, that rather than search all 29 gazillion web pages that Google crawls, you can provide a list of web sites that it searches.

So you can create your own search, to use the Google method to search, say only web sites about literature, or only ones about christmas toys…. okay those are made up. I created one to search among a set of open education sites and one for NMC’s Horizon Project to search among a collection of emerging tech sites… a while ago Leigh Blackall set one up to search Free Media sites — in this case he invited me to join so I can add sites to the list.

Am I on drugs or is this not just a fantastic tool for any teacher? You select the sites that students search from, so they are not trolling among the entire web, or getting lost in cat videos in the results. Or even better, you have your students research and add to the list of the sites included in the tool.

Okay, I digress because I have come across very few teachers using GSE.

But this is where the WordPress plugin is clever. What you do is set up a Google CSE to search just one site, your own blog– I pointed mine at http://cogdogblog.com/

With the Google Custom Search plugin, you copy the code GSE provides into a settings field. You use the GSE approach of embedding the results in your own web site.

Now I got tripped up one something in setting it up- the idea is the the plugin routes the basic WordPress search that looks like http://cogdogblog.com/index.php?s=dogs+rule+cats+drool and sends it to a GSE, and the results that appear on a page at http://cogdogblog.com/search — but no mater what I tried that did not happen.

So I looked at the source code of the GSE search form, and went into my template. Most modern templates have the search form HTML code in a file called searchform.php. I made a copy of that as backup, and replaced the form elements with what the GSE provides– so the search box on my site sends the query to Google, and it shoots the results on my page.

This way, I can use all of the modifiers I do in a Google search, and get relevance ranked results. Another nice surprise is that it is returning things that sit outside my blog, like my presentations under cogdogblog/stuff. Woah Neoh- this is now a site search tool, not just a blog search.

Yes, I have to do some CSS work on the output. And I am not crazy about the ads (I thought of lying on the GSE form about being a registered non-profit or university). And for some reasons the search words dont come through on the form on the results page– but those are just minor things that need a fix.

I’m going to play with it a bit more, but I like it. I am sure someone will comment how I am selling my soul to the Borg by letting Google crawl all over me.

But c’mon WordPress developers, how about creating a search tool that is not start of the art 1996?

UPDATE: Thanks to Joss Winn– I completely overlooked, missed, the WP Search API plugin, which offers either advanced wordpress search or intergation with GSE. I got that one going, and it is more elegant and cleaner, though I am having some challenges on controlling the width of the output. But it seems a better.

UPDATE UPDATE: Tried switching WP Search API plugin to use the MySQL search plugin, but it produced fatal errors. The Google search was less than ideal with some more trying. I alos tried the Relavassi plugin recommended by D’Arcy, but it crapped out each time trying to index (gave up after 5 rounds). I’m stuck back now to basic old WP built in search.

The post "There’s Gotta Be a Better Way To Search a WordPress Blog" was originally squeezed out of the bottom of an old rusted tube of toothpaste at CogDogBlog (http://cogdogblog.com/2010/03/search-wp-blog/) on March 10, 2010.

8 Comments

  • After working w/WP stand alone installs for about 4 years now, I am totally surprised they have not improved the core search function. However, how good is the core search in any CMS like Joomla, Drupal, etc.? I have found all of them to be seriously lacking. You can tweak things a bit behind the scenes, but they never work as well as a Google CSE embedded or plugged into a site.

    As for advocating for CSE in the classroom, this is something I push for in the presentations I’ve done on search. I propose that teachers need to become better at search so they can model and train their students to be effective at sourcing and analyzing information. I see a google CSE as a perfect way to achieve this.

    I have come up with a workflow for CSE if you are hosting one on your own site. This is the best way to achieve this as you can link it with Analytics to see the keywords your students are using. This allows you to provide a feedback and/or remediation on keyword selection to improve search results. http://www.flickr.com/photos/chris_bell/4355361906/

    so yeah, blah blah blah. :)

  • D'Arcy Norman darcynorman.net

    The core WP search is borked. Always has been, likely always will be. I tried raising the point with Matt at NV a couple years ago, but he thought the dumb-search-and-reverse-chronological-display searching was just fine. Maybe that’s changed, but the search still sucks.

    I use the excellent Relevanssi search plugin on mine. It does fulltext, and I believe boolean, searches – and sorts by relevance rather than date. woohoo.

    http://www.mikkosaari.fi/relevanssi/

    No need to rely on Google (or anyone else) to search your own database.

    • No Boolean search in Relevanssi, just full text. My experience (and this is backed by Masters-level studies in the field) says nobody actually uses Boolean search, except maybe few pro searchers. Average Joe certainly doesn’t. Thus, not a top priority feature.

      Relevanssi does support “phrase search” and searches tags, custom fields, categories, expanded shortcodes, comments and trackbacks. Negation operator is not yet supported, but might happen later on.

      WordPress is my #1 choice for a CMS and a good search is a must. I had to write Relevanssi myself, because nothing else did the job the way I wanted.

  • @D’Arcy

    From what I’ve read, Matt would say that considering his aversion to using/building WordPress as a CMS. Posts and pages are the only content types he cares about. So chronological sorting and keyword hits is most important to him.

    With greater occurrence of custom fields out of a) necessity and b) access via wp 3.0’s interface and plugins like Pods CMS, we’ll need to be able to fine-tune our searching to something much more specific than keywords/chronology.

    In the meantime…. maybe check out “Search Engine” by one of the awesome Pods developers, Scott Kingsley Clark: http://wordpress.org/extend/plugins/search-engine/

    ~kyle~

  • Interview with Alan Levine! « Kaylamarlane's Blog kaylamarlane.wordpress.com/2010/04/01/interview-with-alan-levine

    […] There’s Gotta Be a Better Way To Search A WordPress Blog […]

  • That Two Timing XML File - CogDogBlog cogdogblog.com/2010/04/19/two-timing-xml

    […] wrote before about the power of creating a Custom Google Search engine (CSE) — using google’s search tools as a tool to […]

  • Found. The WordPress Search Solution. Hewn by Hand. - CogDogBlog cogdogblog.com/2010/04/24/found

    […] my blog- not that I care if you can find anything here, but its important that I do. Back in March I vented my frustration about the limits of WordPress search, yet despite the experiments with plugins, none of them really worked for me, and one of them just […]

Leave a Comment

All fields are required. Your email address will not be published.