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.
New Features in Version 2.2
- Support for MT 4.1 - A "division by zero" error that was caused by changes in 4.1 has been addressed.
- New 'Type' Option - Optionally, you can now search only Pages or only Entries by specifiying the 'type' argument or URL paramater.
- MT4+ Sort by Date Fix - Fixes an issue under MT4+ when changes to an entry's authored_on date were not reflected in the the sort order, when sorting by date.
- Top Searches Stats and Widget - (Pro only) This new feature tracks your search stats, enabling the creation of "Top Searches" lists.
- Tag Searches no Longer logged - Staring in version 2.2, "tag searches" will not longer be logged. Tag searches happen when someone clicks a linked tag name, so they are not real searches. This change removes log clutter and increases performance of tag search results.
- Code Optimization - For better performance and memory utilization.
Note: Version 2.2 is only supported on MT4 and higher (including MT 4.1). If your are still using MT 3.2 or MT 3.3x, you need version 2.0 (see links below).
Tag Searches with Fast Search
Fast Search 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, 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.
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/2.1 -- 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 versions 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
Fast Search Pro Features
Fast Search Pro includes additional features, including:
Clean Tag Search URLs
You can use nice looking tag search URLs such as:
This feature requires editing your .htaccess file and includes a special "bootstrapping" template to enable this feature.
Top Searches Stats and Widget
Fast Search Pro enables you to track search queries and display lists of "top searched keywords" on your site, linked to the search results page for each keyword. You can list the top searches from the past day, week, month or year -- enabling you to show your readers what keywords are most popular. The search links are compatible with the clean tag URLs described above (ie. http://mt-hacks.com/search/comments) -- making this feature an effective way to increase the number of pages indexed by search engines. Search results pages are highly optimized for the search keywords, making them great for SEO. This is an easy way to add hundreds of SEO-optimized pages to your site, without adding new content. This feature is new in version 2.2 of Fast Search Pro.
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.
- 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">. Set blogs equal to "all" to search every blog on the sytem.
- new - type - the type of object to search. This can be set to either "entry" or "page". If you want to search both entries and pages, then you should omit this argument. Example usage: <MTSearchResults type="page">
- <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
containerconditional tag that displays its content only if no search phrase was specified. 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.
- <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.
- <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.
- <MTIfStraightSearch> - A conditional tag that only displays its contents if the search is a normal search and not a tag search.
- <MTIfTagSearch> - A conditional tag that only displays its contents if the search is a tag search and not a normal search.
- <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.
- <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.
- new - <MTTopSearches> - (Pro only) A container tag that displays a list of top searched keyword phrases. Optional arguments include:
- lastn - the number of keywords to list. Default: 10.
- sort_by - the date range that you want to use for the list. This can be sent to one of "day", "week", "month", "year", with the default being "year". For example, <MTTopSearches sort_by="week"> would display a list of the popular searches from the past 7 days, ranked by the most searches during that time period.
- sort_order - the sort order of the list, default is "descend" (the keyword with the most searches listed first)
- new - <MTTopSearchKeyword> - Used inside a <MTTopSearches> container, this tag will display the search keyword phrase.
- new - <MTTopSearchCount> - Used inside a <MTTopSearches> container, this tag will display the number of searches for the keyword. This tag has one optional argument:
- period - The time period for the count. This can be set to one of "day", "week", "month", "year". If omitted, the count will be based on the sort_order of the list.
- new - <MTFastSearchLink> - Used inside a <MTTopSearches> container, this tag will display the URL to the Fast Search results page for the keyword. This tag has one optional argument:
- search_dir - If you want to use clean search URL, set this argument to the "directory" for your clean search URLs. For example, <MTFastSearchLink search_dir="search"> will create URLs like http://blogdomain.com/search/keyword+here.
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 (Fast Search v2.09)
- Movable Type 4.0+ (Fast Search v2.2)
- Template Installer plugin (included)
- 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).
- Version 2.09 for MT3.2 and 3.3 only: 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 or 4.0+, 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. Note: If you are installing FastSearch for the first time and you don not see an upgrade sceen, then you should follow Step 6: go the the plugin settings and click the link to create the Fast Search index.
- 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 'Plugin Settings' of a blog where you want to use Fast Search. Choose the 'Plugins' 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 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". Version 2.09 for MT3.2 and 3.3 only: 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 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 "Install Tenplates" link. The templates will be created. The "Fast Search" index template is an dynamic 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.
After Upgrading to MT4
After upgrading to MT4 and installing Fast Search 2.1, there is one more thing you may need to do. In MT4, the 'php' folder resides inside /plugins/FastSearch/. But if you installed previous version of Fast Search, you had to upload the 'php' files to /php/plugins directory. Now that you have upgraded to MT4 and Fast Search 2.1, you need to delete those files from /php/plugins.
The Search Form
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" /> </form>
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.
<input type="hidden" name="type" value="entry" />
...to restrict the search to only entries.
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.
Get Fast Search Pro
After purchasing a license below, you will be taken directly to a download page with a link to download Fast Search Pro, which includes the "clean tag URLs" and Top Searches features described above. See the text file included with the download for instructions)
Get Fast Search
Fast Search is FREE for non-commercial use ( although you must include a
Movable Type search results powered bylink on your search results pages.
<a href="http://mt-hacks.com/fastsearch.html">Fast Search</a>
Membership required, please sign-in or register:
As always, suggestions and feedback are appreciated. Please reply to this entry.
Note: FastSearch 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 does not include. Fast Search 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.