AutoSuggest Search

This project is not covered by Drupal’s security advisory policy.

AutoSuggest Search is a lightweight module aimed at extending autocomplete / type-ahead support to the native Drupal search. Using stock Drupal jQuery functionality, each keystroke within the search input triggers an AJAX request which quickly searches through your sites node titles (filtered by configurable content-types). The response to this AJAX request is a JSON encoded object that jQuery turns into AutoSuggested items. It's a fast and effective way to get AutoAuggest support for your site's search block.

This module does not make any changes to your database or leave any trace when uninstalled. Some features include per-role access permissions, AutoSuggested items link directly to the suggested node, search queries get highlighted within the AutoSuggested items, and queries are matched within node titles (as in "example" query will match against "some example" node title).

Tests have shown very acceptable latency averaging 100-200ms response time, sometimes even below 100ms (tested with ~8,000 nodes). Single character queries do take longer and note there is an integrated 180ms delay between keystrokes and sending new AJAX requests to help account for fast-typers and unneeded queries.


Installation Notes

  • Make sure you have the Search, Path, and JS callback handler modules installed and enabled
  • Enable the normal Search block at Site Building > Blocks (/admin/build/block)
  • Adjust your site's Permissions at User Management > Permissions (/admin/user/permissions) and enable "Access AutoSuggest" for the appropriate roles as well as "Search Content"
  • Configure AutoSuggest at Site Configuration > AutoSuggest Search (/admin/settings/autosuggest)
  • You need to determine the CSS ID of the Search block's form element and specify that in the AutoSuggest settings page. By default it is specified as the CSS ID of Garland's Search block, #search-theme-form. For example, replace [] with <> -- [form id="my-themes-search-form"] would mean you need to set #my-themes-search-form in AutoSuggest Settings page. [will be improved in the next release]

Todo list:

  • Remove the form CSS ID specification requirement via hook_form_alter implementation and adding a class (thanks for the suggestions, berdir)
  • Add per-theme support
  • Add custom block
  • Settings page (need to add additional options)
  • Documentation
  • Cache table with fulltext index

Also check out these other excellent options for autocomplete / type-ahead / autosuggest support:

AutoSuggest Search项目的Drush安装命令:复制到剪贴板