Views Fast Search
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 is also a proof of concept of a solution using alternative search SQL that could be used as a basis for a patch to core.
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.
This module is partially supported by CivicActions and The New York Observer.
The new improved views fastsearch development is mostly done. It’s time for testing and fixing!
- significantly faster than the previous fastsearch
- solves the multi-term join problem (5-6 term searches on large sites experienced slowness; plus mysql limits joins to 21 tables)
- fixes for OR and EXCLUDE terms
- added score field
- better score sorting, not perfect yet
- added search results view
To use the 5.x-dev branch, you must:
- ALTER TABLE search_index ENGINE=MyISAM; (you must do this yourself, but a warning is shown on admin/settings/search if this is not done)
- ALTER TABLE search_index ADD INDEX (fromsid, word); (now part of the update .install process).
- ALTER IGNORE TABLE search_index ADD UNIQUE INDEX (sid, word, type, fromsid); (see #143160, now part of the update .install process).
- admin/settings/search – select UNIQUE
- admin/settings/search – set the number of comments node rank to 0 (without which the performance results are not reproducable)
Thanks to Moshe for his ideas on the search HAVING clause (which is very similar to how core search does it) and for discovering ALTER IGNORE TABLE. And credit to Robert for pointing out that search_index had a dup problem in the first place.