The views_fastsearch module provides a faster functionally equivalent alternative to the views "Search: Index" filter. This search is considerably faster (than the search in views_search.inc), supports OR terms, exception terms, and sorting by score.
- It is noticeably faster - 5-20x faster
- defaults to AND terms, but supports the OR keyword
- implements exception terms using the – prefix (i.e., “global warming –ocean” searches for nodes that include “global” and "warming" but do not include “ocean”)
- implements a sort by the search word score, when there are multiple terms, it sums them up – this presents results where the search words are in the title or header tags higher up in the list
This module was the proof of concept of a solution using alternative search SQL that made it into 6.x core. The 6.x implementation is different (better) than this one, but both provide similar speed enhancements. The primary difference is that the 6.x implementation offers better query term support.
See also the contrib module vfs_ranking_nodetype packaged views_fastsearch, for an example of how to write a hook_search_ranking to extend the scoring factors used in the search results. See also #145242.
The speed tests were done on a Drupal install with over 30,000 nodes. Additionally speed improvements can be found by:
- create an index on search_index(fromsid, word)
- enable the mysql query cache - causes the COUNT() query to be cached speeding up secondary page searches
set global query_cache_size=50000000;
- InnoDB is much slower than MyISAM for selects, so it is highly recommended that the search_index table not be InnoDB. A check has been added to the admin/settings/search page to warn when InnoDB is used.
Views_fastsearch only filters based on the search results. When creating any view, you typically should also add a view filter for "Node: Published" to filter on only published nodes.
The module uses SQL subselects to implement exclusionary terms, and thus requires mysql 4.1 or higher.