New search method from Google

Sometime ago I moved to a new server because my previous Host just didn’t support my use of Moveable Type. They severely restricted the program to where it was useless to me to have on a regular basis.

I moved to a new host who I learned didn’t restrict the use of MT scripts and especially didn’t after I bought a virtual server.

A few months into the new arrangement my blogs started going down on a regular basis. The server would crash so bad that it didn’t exist when you tried to visit. I upgraded the memory 3 times and was still getting crashes.

The problem is mt-search.cgi file in the base install of my MoveableType v3.36 I used the script for Tag searches on the site. What happens is some yahoos run a script that crawls the site and hits every tag which causes the script to fire. The overhead would build up and crash the server.

I immediately disabled the mt-search script and the crashes stopped.

The problem is a blog is really not whole unless a visitor can search it. It would especially make the Tag feature useless since tags are just a search keyword that serves up posts with that keyword.

I looked for another solution.

One I tried was a PHP whole text search plugin that was suppose to be fast but after following the instructions to the letter and spending several hours, I still couldn’t get it to work with my blog (although the basic version did work with Doug’s Views). The basic support for the script was lacking. I kept having an issue with mod_rewrite exceeding the max redirects with Moveable Type’s base htaccess file declaration for dynamic publishing – which was needed for the plug in to work. No dynamic publishing no search.

I found a solution that didn’t require a phd in computer script programing and server mechanics.

Google has a product called Custom Search Engine. You use your current Google account or get one, and CSE allows you to create a custom search – you can host the form and results on your site, use Google for the results, place your own ads on the results, limit the search to certain pages, include more than one site. The one downside is you have to put up with ads on the results page.

Once you setup the base search engine then Google provides the code to put on your blog to display the search box and results. I haven’t figured out how to host the results myself yet but Google will serve the results for you.

The cool thing is I can still have Tag searches by writing a URL that will pass the info to CSE as if you used a search box. Here is the example of my code I use in my MT templates:

"a rel="tag" href="<$MTTagName encode_url="1"$>&cx="your value will very here"><$MTTagName$>"

Now when I click on a Tag in the entry or on my Tag Index it brings up a Google search results page with hits on that Tag.