Drupal is a registered trademark of Dries Buytaert

About

This module provides enhanced autocomplete functionality with optimized caching and accurate result counting for Search API Solr autocomplete. It automatically discovers views and search_api configuration from search_api_autocomplete entities, eliminating the need for manual configuration.

Features

  • Automatic views and search_api discovery: Dynamically extracts views and search_api index information from search_api_autocomplete Search entities
  • Automatic duplicate removal: Eliminates duplicate suggestions based on normalized text
  • Accurate result counts: Calculates real result counts for each suggestion
  • Optimized caching: Uses Drupal's cache system with cache tags for proper invalidation
  • Automatic cache invalidation:
    • When search index is updated (via event subscriber)
    • On via generic drush cr (cache rebuild)
  • Zero configuration: Works out of the box with any Solr with Views autocomplete search

The problems we try to solve

  • The count of the suggestions results is not correct (see option "Display result count estimates"). This is because the Solr suggester uses suggester instead of query.
  • The number of the results in a suggester Solr component does not show the documents found (df) but a term frequency number (tf).
  • The module search_api_solr (or any related) allows suggesting new Solr terms without any validation.
  • We may end up with no results on Views even if the autocomplete keyword says it has results (usually a multi word result).
  • The Solr suggester adds any new token at the end of the prefix without checking if the whole phrase has results. For example on the prefix product original it may suggest the suffix 2026 so the final keyword value is ireland original2026 which has no results. But it has results for product original and 2026 individually.
  • The autocomplete shows duplicate keywords. This is happening when using multiple search_api_autocomplete Suggester plugins.
  • The suggester adds suffixes that generate words which do not exist on the indexed values. For example it can suggest "peoples" when we type "people" in autocomplete.

Most of the issues are coming from the search_api_solr module.

How it works

The module uses hook_search_api_autocomplete_suggestions_alter() to alter the suggestions provided by search_api_autocomplete. The hook implementations are available in src/Hook/SearchApiAutocompleteImprovedHooks.php.

For each suggestion we do an additional call on Solr or Views to count (but with a cache on it to avoid performance issues).

For backward compatibility with Drupal 10, procedural hooks are maintained in the .module file. Drupal 11 will automatically use the new OOP hooks.

Plans

  • Add tests similar to these on search_api_solr
  • Optimize caching further with more advanced cache tags
  • Create a new search_api_solr Suggester that fixes the issues described above

Activity

Total releases
4
First release
Jan 2026
Latest release
2 weeks ago
Release cadence
5 days
Stability
75% stable

Release Timeline

Releases

Version Type Release date
1.0.2 Stable Feb 12, 2026
1.0.1 Stable Feb 11, 2026
1.0.0 Stable Jan 29, 2026
1.0.x-dev Dev Jan 29, 2026