Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: Opensolr Search 4.5.0 Minor update available for module opensolr_search (4.5.0). Release: Block Layout Accordion 1.0.2 Minor update available for module block_layout_accordion (1.0.2). Release: Canvas interactive toggle 1.0.2 Minor update available for module canvas_interactive_toggle (1.0.2). Release: Views HTTP Client 1.0.2 Minor update available for module views_http_client (1.0.2). Release: Block Layout Accordion 1.0.1 Minor update available for module block_layout_accordion (1.0.1). Release: Canvas interactive toggle 1.0.1 Minor update available for module canvas_interactive_toggle (1.0.1). Release: Video.js (HTML5 Video Player) 10.0.0-alpha1 First alpha version released for module videojs (10.0.0-alpha1). Usage Milestone: Simplify Module simplify crossed 10,000 active installs. Release: Audit Trail 1.0.0-alpha7 New alpha version released for module audit_trail (1.0.0-alpha7). Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

Search API Autocomplete: improved

17 sites Security covered Drupal 10–11
View on drupal.org

This module enhances autocomplete functionality for Search API Solr by automatically discovering configurations, removing duplicate suggestions, and providing accurate result counts with optimized caching. It aims to fix issues with incorrect result counts, duplicate suggestions, and inaccurate autocomplete suggestions from the underlying Solr suggester.

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

Depends on

Dependencies of the latest stable release

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
4
Tracked since
Jan 2026
Latest release
6 months ago
Releases (12 mo)
4 ▲ from 0
Maintenance
Slowing

Release Timeline

Releases

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