The Search API Autocomplete module has for some years now been a popular way to add autocomplete suggestions to search fields while the user is typing. However, even though the module was popular, it had several problems and restrictions – primarily, the way the suggestions are computed only reflect the words that are indexed on the search server, not the keywords that users actually searched for. Changing this was possible (as is nearly everything else in Drupal, after all), but cumbersome, and not directly supported in any way by the module.
But, these days are now finally over with the release 1.4 of the module! Due to a few companies sponsoring these improvements, this release finally includes some much-needed love for the module, bringing with it a lot of additional flexibility for advanced or different use cases:
- While the default mechanism how suggestions are computed hasn't changed, it is now much simpler to customize this on your site by providing a new so-called suggester plugin which uses your own logic for computing suggestions. The default mechanism is now just the only such plugin provided by the module itself. (However, more might follow soon – e.g., one using search statistics to suggest often-used keywords and combinations.)
- Then, the structure used internally to represent autocomplete suggestions (returned from the server or from such a suggester plugin) was expanded to also allow returning direct links instead of suggestions – thus making it possible to create experiences similar to the Search API Live Results module. Or even mixed lists of both suggestions and results, or suggestions for different searches.
- Finally, if you find the autocomplete takes too long on your site, thus decreasing its UX value, there is now an easy method to use a custom script for creating the autocomplete suggestions. With that, you can easily avoid bootstrapping Drupal, thus greatly increasing the autocomplete's speed. (It is now also possible to change the delay after which the autocomplete request is triggered, which could also help improve the user experience of the feature on your site – but should be weighed against the possible drain on resources this might entail.)
- There were also some bug fixes and smaller features added to the module. You can read the complete release notes if you are interested in the details.
While these improvements will, at the moment, not directly benefit site builders without some custom code, it will hopefully make it much easier to use the module as a foundation to build a rich autocomplete experience for the searches on specific sites. Also it paves the way for adding such improvements (e.g., statistics-based suggestions or live results) directly to the module in future releases – so definitely keep an eye out for those! (Also, please contact me if you are interested in sponsoring any such feature.)