Fast Search is a PHP plugin for Movable Type. This means that Fast Search uses Movable Type's dynamic PHP-based publishing system to display search results. However, you can continue to use static publishing for all of your indexes and archives. Fast Search is fast in part because it uses mySQL fulltext indexing -- basically this means that a search index will be created for the entries in your database, making searches much faster. Like the built-in search, Fast Search logs searches to the Movable Type Activity log.
Version 2.02 has been released. This is a critical update for those who installed 2.0 prior to March 10, 2007. Inadvertently, the old version of the MTSearchString tag was included in that zip file. Version 2.02 has the correct version of that tag. Note: if you don't plan on using Tag Search, then you don't really need 2.02.
Version 2.03 has been released. This version addresses a Unknown column 'mt_entry.entry_id' in 'on clause'
error that affected people running mySQL 5+. (A big thanks to David Chiu
for providing the fix!)
New Features in Version 2.0
Fast Search v2.0 has several new features:
- Tag Search. Fast Search now supports Tag Search (MT3.3+). Also known as a tag listing, Tag Search displays a list of entries with a specific tag. If you list tags in your entries, they are probably linked to a Tag Search. Fast Search v2.0 does the same thing, only faster.
- Better Relevance Ranking. Fulltext searches now provide much better relevance ranking.
- Easier System-wide Searching. Now it is even easier to to search all blogs in a single search.
- Search results containing all keywords. This is a small change for Fulltext searches. Previously, if you searched for 'red books' (without quotes), the search results would include any entry containing 'red' or 'books'. In version 2.0, only entries with both 'red' and 'books' will be included in the search results. This makes things more consistent with other search engines.
- Fast Search Widget. A new Fast Search Widget makes it easy to add a Fast Search form to your sidebar.
- New Template Tags. Several new template tags make it easier to customize your search results. Fast Search now supports all of the template tags used in the default MT 3.3 search results template -- this means it is even easier to switch to Fast Search
Tag Searches with Fast Search
Fast Search now supports tag search. A tag search will display a list of all entries with a specific tag. Of course, tag searches have the same pagination features as regular searches, enabling you to browse multiple pages of tag search results. Tag search results are always sorted with the most recent entries listed first. Tag searches can done on a single blog (default), or across multiple blogs.
Tag Search Links. If you are using tags with MT 3.3+, you are probably displaying a list of tags with each entry. Each of those tags are linked to a search results page that displays all the entries with that tag. Since those links point to the built-in mt-search.cgi script -- Fast Search includes a new version of the <MTTagSearchLink> tag that points to the Fast Search script. This happens automatically, you don't have to edit your templates -- just enable Fast Search, install the Fast Search template, then rebuild your pages -- the tag links will be automatically updated.
Clean Tag Search URLs
With Fast Search 2.0, it is possible to use nice looking tag search URLs such as:
This feature requires editing you .htaccess file and a minor edit to the Dynamic Bootstrapping template. This feature is only available to those who purchase a license or those personal users who donate at least $33. I will email you the required files and full instructions.
By tweaking the fulltext queries, I have managed to improve the relevancy ranking significantly. To test this out, you should do a few searches (in fulltext mode) before you upgrade to Fast Search 2.0 -- note the results and their relevancy -- then upgrade and do the same searches. You should see much more relevant results at the top of the search results. Please post your feedback on this by replying to this entry.
Search all Blogs Easier
In the previous version of Fast Search, it was possible to search across all blogs on a system, but you had to specify each of them separated by commas. This is fine if you have a few blogs, but what if you have 50? 100? 500? Version 2.0 makes this easier by allowing the special "all" keyword to indicate that you want to search all blogs (example <MTSearchResults blogs="all"> or in the URL/form: ?query=books&blogs=all). A time-saver for large MT installations and blog networks.
Include PHP in your Search Results Template
This not a new feature, but it deserves highlighting. Many sites use PHP on most of their pages for various reasons (for example, to include content such as headers/footer and advertising blocks). The problem is that you can't use PHP on the "built-in" search results pages, because they are dislayed by a (Perl) CGI script. This can make it challenging to maintain your site in a consistent manner. You can avoid such problem with Fast Search -- since it is powered by PHP, you can include blocks of PHP code in the search results template. (Note: there is a small requirement that you need to use <?php to start each block, using simply <? won't work.)
What Search Method is Best?
For most cases, "Fulltext" will be the fastest search method. This is the same method used in version 1.0. There are some cases in which you might two options:
- Non-Fulltext. Technically speaking this method used a LIKE %query% syntax. If you don't know what that means, don't worry about, just read on.
- Fallback. The Fallback method is a combination method. FastSearch will first try a fulltext search, and if that returns no results, then it will try a Non-Fulltext search.
Non-Fulltext and Fallback are capable of some types of searches that you can't do with mySQL. You might want to use Non-Fulltext or Fallback to:
- search multi-byte languages such as Arabic and Japanese.
- search words shorter than 3 characters (such as "MTV")
- search partial words
- search a mySQL database that does not support Fulltext searching
Version 2.0 of FastSearch is designed to easily replace the existing search functionality in Movable Type, but with added features. For example, if you are currently using customized search templates, you can use them with Fast Search, with very few changes in most cases. Many Fast Search template tags have the same names as their CGI counterparts:
- <MTSearchString> - The search string (query) being searched.
- <MTSearchResults> - A container tag that displays search results. Arguments include (all are optional):
- lastn - restricts the search to n results. (example <MTSearchResults lastn="10"> ) The lastn argument, like all arguments for MTSearchResults, can also be specified in the URL (...&lastn=10) or POSTed from a search form)
- offset - used in coordination with lastn, starts M entries from the start of the list. (example <MTSearchResults lastn="10" offset="10"> will display results 11-20)
- order - must be either 'date' or 'relevance', the default is 'relevance'. (example $lt;MTSearchResults order="date"> will provide similar results as the CGI search)
- category - must be a valid category ID for the current blog - restricts the search results to entries from this category.
- google_highlight - if specified, search words will be highlighted. (example <MTSearchResults google_highlight="1"> )
- query - the search string (text) to be searched. In normal use, you would NOT include this argument as part of the <MTSearchResults> tag, rather, it would be specified as a URL paramter (example ...query=search+phrase) or POSTed from a search form.
- new - tag - the tag to be searched. In normal use, you would NOT include this argument as part of the <MTSearchResults> tag, rather, it would be include as a URL parameter (example ...tag=books) as part of a Tag Search Link.
- blogs - a comma-separated list of blog_ids if you want to search more than one blog. This argument is optional, if excluded, only the current blog will be searched. Example usage: <MTSearchResults blogs="1,3,8">new - Set blogs equal to "all" to search every blog on the sytem.
- <MTBlogResultHeader> - this is container tag that displays content before the search results.
- <MTBlogResultFooter> - this is container tag that displays content below the search results.
- <MTNoSearchResults> - A container tag that displays its content only if zero results are found. Note that this tag must be used after a <MTSearchResults> container.
- <MTNoSearch> - A
container conditional tag that displays its content only if no search phrase was specified. new - Now supports the use of <MTElse> inside this container.
- <MTSearchCount> - The number of search results displayed on the current search results page. This tag should be used with a <MTBlogResultHeader> or <MTBlogResultFooter> container.
- <MTSearchFirst> - The number of the first search result on the current page. This tag should be used with a <MTBlogResultHeader> or <MTBlogResultFooter>container.
- <MTSearchLast> - The number of the last search result on the current page. This tag should be used with a <MTBlogResultHeader> or <MTBlogResultFooter>container.
- <MTSearchIfNextPage> - A conditional tag that displays its content if there is a subsequent page of search results. This tag should be used with a <MTBlogResultHeader> or <MTBlogResultFooter>container.
- <MTSearchNextPageLink> - Output a URL to the next page of search results. This tag should be used within <MTSearchIfNextPage> tags.
- new - <MTSearchIfPreviousPage> - A conditional tag that displays its content if there is a previous page of search results. This tag should be used with a <MTBlogResultHeader> or <MTBlogResultFooter>container.
- new - <MTSearchPreviousPageLink> - Output a URL to the previous page of search results. This tag should be used within <MTSearchIfNextPage> tags.
- <MTSearchTotalResults> - The total number of matching results in the database.
- <MTSearchPages> - A container tag that can display links to multiple pages of search results. Optional arguments include:
- max - the maximum number of page links to display on each page. Example: <MTSearchPages max="20">
- glue - a text string that seperates each page. For example, if you wanted to display 1 - 2 - 3 - 4, you could use <MTSearchPages glue=" - ">
- <MTSearchPageNumber> - Displays the page number of each search results page. This must be used within a <MTSearchPages> container.
- <MTSearchPageLink> - Displays the URL to each search results page. This must be used within a <MTSearchPages> container.
- <MTSearchIfCurrentPage> - A conditional tag that only displays its contents if the page number is the same as the current page - you would normally use this is you wanted to highlight the current page in the list of page numbers, etc. This must be used within a <MTSearchPages> container.
- new - <MTIfStraightSearch> - A conditional tag that only displays its contents if the search is a normal search and not a tag search.
- new - <MTIfTagSearch> - A conditional tag that only displays its contents if the search is a tag search and not a normal search.
- new - <MTFastSearchScript> - This tag displays the filename of your Fast Search script. You can use this in your search forms as shown below. Note: for this tag to work, you should not rename your Fast Search template -- it should laways be named "Fast Search". This tag works in both static and dynamic templates.
- replacement - <MTTagSearchLink> - This tag overrides the built-in tag of the same name (this automatic, not need to edit templates or anything). The new version of the tag is "smart" -- if Fast Search is enabled for a blog, it will link to the tag search results using the Fast Search script -- if not, it will use the built-in search script. This tag has the following optional argument:
- tag_dir - Use this argument to specify a "directory" name for your tag search URLs. Note: This feature is only available to personal users who make a donation OR those who buy a commercial license.
Note: the new default Fast Search template includes pre-formatted template code that displays Google-style search results page links.
As you may have noticed, some of the tags above are identical to the ones used for the existing CGI-based search results. This is by design, so you will easily be able to cut-and-paste your existing search template code into the Fast Search template, though some minor modifications may be required.
Here are some working examples you can try. Feel free to try additional search queries and note the speed that searches are performed.
- Tag search results on MT Hacks. Example tags: spam cms.
- Mars Rover Blog has over 5,000 entries. Example search: "water on mars". Note that this example shows the default FastSearch template, which is very similar to the default search results template in MT 3.2.
- Seinfeld Blog has over 8,000 entries, 180 of which consist of the episode descriptions and scripts of all 180 episodes. Fast Search powers the Seinfeld Script Search, which is restricted to a single category containing the episodes. Example search: 'bubble boy'
- Movable Type 3.2 or 3.3
The Search Form
- Download the plugin and expand the zip file.
- Upload the contents of the 'plugins' folder to the 'plugins' directory of your MT installation (usually something like /cgi-bin/mt/plugins).
- Upload the contents of the 'php' folder to the 'php' directory (usually something like /cgi-bin/mt/php)
- Login to the MT admin interface. If you already logged in, choose 'Main Menu'
- If your are running MT 3.3, you should be redirected to an 'Upgrade' screen at this point. The Fast Search upgrade process will update your database to add a fulltext index to the table in your database where entries are stored. Note that this may take some time if you have many entries, and this will add to the overall size of your database.
- If you are running MT 3.2, you will not see the upgrade screen (as it is a 3.3 feature), so you need to create the index by browsing to the 'Settings' of a blog where you want to use Fats Search. Choose the 'Plugins' tab then find 'Fast Search' and choose 'Settings'. Now click the link in bold that says "Click here to create or rebuild the FastSearch fulltext index". Again, this may take some time, please be patient. After the index has been created, hit the Back button.
- Now browse to the 'Publishing' settings tab for the blog, and scroll down to the Setting called "Dynamic Publishing". If the first option, "Build all templates statically", is selected, you should change this setting to "Set each template's Build Options separately" and click "Save Changes" at the bottom of the screen. Otherwise, you don't need to make any changes here.(Note that change this setting will create an .htaccess file in the root path of the blog. Normally you won't notice this and everything will work fine, but if you have an existing.htacces file, you may want to take a look at it to make sure everything looks okay)
- If you just changed your Dynamic Publishing settings in the previous step, you should now rebuild all files for this blog by choosing "Rebuild Site" from the left menu, then "Rebuild all Files". You should also ensure that you have a "Dynamic Site Bootstrapper" (mtview.php) index template and make sure that it gets built, if it hasn't been built previously.
- Now return to the Fast Search settings ('Plugins' tab within 'Settings') and check the box to enable Fast Search. You may also want to adjust the settings for Maximum Search Results and logging, then click "Save Changes".
- Open the Fast Search settings once again and choose "Click here to install the default Fast Search Template." The template will be created and then displayed. This is an dynamic Index template (which can be customized) used to display the search results. (If desired you can also skip this step and create the index template manually, use the template tags as desired, or by cutting and pasting your exisiting search template code)
Upgrading Fast Search
Follow steps 1 to 3 above, then adjust your Fast Search plugin settings and search template, if desired. If you using Tag Search, you probably want to update your Fast Search template. One way to do this is to rename or delete your existing template, then reinstall the new default template from the plugin settings area.
If you already have search forms on your blog pages, you need to update them to point to the new Fast Search template. For each template that contains a search form, look for the following (or similar):
<form method="post" action="<$MTCGIPath$><$MTSearchScript$>"
...and change it to:
<form method="post" action="<$MTBlogURL><$MTFastSearchScript>"
...save the template and repeat this step for every template that has a search form.
If you want to insert a new search form on your site, or completely replace existing forms, you can use the following:
<form method="get" action="<$MTBlogURL$><$MTFastSearchScript>">
<label for="query" accesskey="4">Search this blog:</label><br />
<input id="query" name="query" size="20" />
<input type="submit" value="Search" />
Or better yet, install the new Fast Search Widget from the plugin settings area, and use WidgetManager to add the widget to your sidebar (you should also remove the existing search widget).
Of course you can also add optional fields to the form such as:
<input type="hidden" name="order" value="date" />
....to sort the results by date, or....
<input type="hidden" name="category" value="5" />
...to restrict the search to category_id = 5.
Once you have the search form(s) on you site, rebuild those pages and start searching. You should notice significant speed and resource improvement, especially on blogs with many entries.
Fast Search Settings
Fast Search settings are on a "per blog" basis. To access the settings, browse to the blog you want to use, then choose "Settings", then "Plugins". Look for Fast Search in the list and click the "Show Settings" button.
Download Fast Search
Non-commercial use - FREE ( although you must include a
Movable Type search results powered by
<a href="http://mt-hacks.com/fastsearch.html">Fast Search</a>
link on your search results pages.
Also, donations are appreciated. Those who donate at least $33 will receive the BONUS "clean tag URLs" feature described above:
Commercial use - (up to 5 blogs) - $97.00
Blog Network License - (more than 5 blogs) - $249.00
Downloads: 4783 (since 3/6/07)
Membership required, please sign-in or register:
As always, suggestions and feedback are appreciated. Please reply to this entry.
Note: FastSearch v2.0 is a suitable replacement for most implementations of the built-in search function in Movable Type. However, there are a few features that Fast Search v2.0 does not include. Fast Search v2.0 does not support comment searches, regexp search, case-senstive search, the use of AND and OR operators, and Edit Entry Links). Some of these features may be supported in future versions -- please let me know what features you would like to see.