Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Search API Relevance

No security coverage Under active development

Part of the Search ecosystem · 127 projects

Search API Relevance shows what visitors search for on a Search API site and which searches find nothing, and lets you fix them with query-time synonyms, pins, boosts and hidden items, each replayed against real logged searches before it is approved. An optional AI submodule drafts synonym proposals but never applies them.

Status: Stable. 1.0.0 is the first release.

Why

Search API keeps no record of what visitors typed, so a search that fails stays invisible until someone complains. A fix is easy to get wrong: a synonym or a pinned result that helps one query can change many others. This module logs searches without identifying anyone, shows which ones fail, and runs a proposed change against the searches people actually made before anyone approves it.

Features

Search log and reports

  • Every executed search with keywords is logged after the response is sent: the index, the search ID (such as a Views display), the redacted and normalized keys, the parse mode, the language, the result count, the page and the time. No IP address, user ID, session, cookie or User-Agent is stored.
  • Email addresses, payment card numbers and phone numbers are replaced with [email], [card] and [phone] before anything is stored; the phone pattern also catches any other run of 7 to 15 digits. The patterns can be edited, and if one fails to run, the search is not stored at all.
  • By default only keywords that came with the request are logged, so keys fixed in code or in a view are left out. Self-declared crawlers, autocomplete requests and the module's own replays are skipped.
  • A sample rate (100% by default) that the reports scale their counts by, a retention period (90 days by default) enforced on cron, and a daily limit per index (100,000 by default) against crawlers that do not announce themselves.
  • Four reports, filtered by index, language and period: Top queries; Zero results, which says "Found results since" when a later search for the same words found something; Click-through; and Trends.
  • Optional click tracking, off by default: a small script on Search API views with an exposed fulltext filter sends the index, the query and the clicked result's position. The endpoint refuses cross-site posts, rate-limits each visitor with core flood control, and counts a click only for a search logged in the last day.
  • Logged searches can be deleted all at once, per index, or only those containing a given text, for erasure requests. Deleting by text also removes the query from stored replays and its pending and rejected proposals.

Synonyms, pins, boosts and hidden items

  • Two Search API processors, enabled per index: "Synonyms (query time)" and "Ranking rules (pins, boosts, hidden items)". Both work at query time and need no reindexing.
  • Synonym sets per index, for every language or for one: equivalent (every term finds every other term) or one-way. A multi-word term is searched as a phrase. Negated words and the "Direct query" parse mode are never expanded.
  • The expanded query is built in the form each backend reads correctly: one form for the database backend, one for Search API Solr, kept under a clause count you set (640 by default, below Solr's limit of 1,024), and nested groups for other backends. Search API Solr's "Multiple words with EDisMax" parse mode gets no synonyms.
  • Ranking rules apply when the query is exactly a trigger or contains one as whole words. A rule can pin items to the top in order, multiply an item's score (above 1 lifts it, below 1 buries it) within a re-rank window of 50 results by default, and hide items. Items are picked from the index with autocomplete, or named in a proposal by their page's address.
  • Pins and boosts apply only while results are sorted by relevance; hidden items stay hidden under any sort. A pinned item is shown only when the search's filters, access checks and the words the visitor excluded allow it.
  • Synonym sets and rules are configuration entities, so they are exported and deployed with configuration.

Proposals, replay and approval

  • A proposal is a new or changed synonym set or ranking rule waiting for review, created from the Zero results report, by hand, or by the AI submodule. On an index without the matching processor it says so, with a link to the index's Processors tab, and cannot be replayed or approved until the processor is on.
  • Replay runs the most searched logged queries (50 from the last 30 days by default) twice on the live index, with and without the change, through the Views display each was logged from where there is one, as a stand-in user with a role you choose (anonymous by default). It lists the queries that now find results, now find nothing, find more or fewer, or show different top results (the top 10 by default). A replay stops at its query limit and time budget.
  • Approval requires a replay of the change exactly as it stands, and the Administer search relevance permission. Editing the proposal makes its replay stale, and approval is refused if someone edited or replayed it while the review page was open. Who approved or rejected a proposal, and when, is recorded on it. A rejected query is not proposed again automatically.
  • Drush commands to list the top and zero-result queries, purge the log, list proposals, and replay, approve or reject one, under the same approval rules.
  • Status report entries for logging or redaction switched off, a daily limit reached, a purge backlog, synonym sets or rules on an index without the matching processor, and proposals waiting for review.

Optional AI submodule

  • Search API Relevance AI (search_api_relevance_ai) asks a chat model, through the AI module and any chat provider it supports, for other words a visitor could have meant when a search found nothing.
  • Every suggested term is searched on the index first. Terms that find nothing are dropped, and so are terms that match more than a quarter of the index (a setting). The rest become a one-way synonym proposal, which needs a replay and an approval like any other. Nothing is applied automatically.
  • Drafts on demand, from "Ask AI" on the Zero results report, a form or Drush, and optionally on cron, off by default and at most 100 requests a day. Sent to the provider: the query, redacted again, the index label, the language and any instructions you add; no other visitor's searches.

Requirements

  • Drupal 11.3 or later, or Drupal 12.
  • PHP 8.3 or later. The intl extension is optional; with it, report numbers follow the interface language's conventions.
  • Search API 1.43 or later. Logging, reports and click tracking work with any backend; synonyms and ranking rules are written for the Database backend and Search API Solr.
  • Optional: core's Views, for click tracking on Search API views, and Drush, for the commands.
  • For the AI submodule: the AI module 1.5 or later with a configured chat provider. The submodule follows the AI module's own core support.
  • Any database Drupal supports (MySQL or MariaDB, PostgreSQL, SQLite).

Installation

Install with Composer, then enable the module:

composer require drupal/search_api_relevance
drush en search_api_relevance

Logging starts as soon as the module is enabled. To use synonyms and ranking rules, enable the "Synonyms (query time)" and "Ranking rules (pins, boosts, hidden items)" processors on each index's Processors tab. For AI proposals, install the AI module and a chat provider, then run drush en search_api_relevance_ai.

Configuration and permissions

Settings are at Administration » Configuration » Search and metadata » Search relevance (/admin/config/search/search-api-relevance): logging, redaction patterns, click tracking and replay limits, with tabs for Synonyms, Ranking rules, Proposals and, with the submodule, AI. "Delete logged searches" is linked from the settings. The reports are at Reports » Search relevance (/admin/reports/search-api-relevance).

  • View search relevance reports (restricted): see the reports, which show what visitors searched for, and the queries listed in a replay. Stored searches are redacted, but free text can still contain personal details.
  • Propose and replay relevance changes (restricted): create and edit pending proposals and replay them against the live index. It cannot approve or reject them.
  • Administer search relevance (restricted): change the settings, including the AI submodule's, edit live synonym sets and ranking rules, approve, reject and delete proposals, and delete logged searches.
  • Ask AI to draft relevance proposals (restricted, AI submodule): send zero-result queries to the configured AI provider. Each request costs money and sends the redacted query to a third party.

What it does not cover

Redaction catches patterns, not names: free text can still hold a name or an address, so keep the retention period short and use "Delete logged searches" for erasure requests. Synonym sets are not chained and inflected forms are not expanded, so put every form of a word in one set. In languages written without spaces, such as Chinese, Japanese and Thai, a term inside a longer query is not found. Pins are Search API item IDs, which include the language and differ between environments. Approving a proposal changes active configuration: export it afterwards, or a later configuration import removes it.

Similar projects

Checked on drupal.org in November 2026.

  • Search API Synonym manages synonyms by hand. Choose it if a hand-kept synonym list is all you need.
  • Search API Stats collects basic statistics on Search API searches. Its latest release is from 2024.
  • Search Log has only a development release, for Drupal 8 and 9, and is marked unsupported.

Support and maintenance

Report bugs and ask for features in the issue queue. Each release has notes describing what changed.

This project is not covered by Drupal's security advisory policy. Until it is, security issues are handled in the public issue queue and fixed in ordinary releases.

A read-only mirror is on GitHub at DanePete/drupal-search-api-relevance; development and issues stay on drupal.org.

Maintainer

Created and maintained by deadnorth (Dead North).

Drupal 11 · not 10 PHP >=8.3

Ask your assistant about Search API Relevance

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

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
1
Tracked since
Dec 2026
Latest release
59 minutes ago
Releases (12 mo)
1 ▲ from 0
Maintenance
Active

Releases

Version Type Core PHP Release date
1.0.0 Stable 11 PHP >=8.3 Dec 2, 2026