Review main Work in progress

94015[FEATURE] Rank live search results by relevance

Benjamin Kott CR 0 V 0 Expert +1794 −608 updated 11/19/26, 12:46

Commit message

Live search asked every search provider in turn, concatenated the
results in provider order and grouped them by record type in the
user interface. Within a provider, records were ordered by uid, so
the record matching a query best could end up on the last page.

Results are now ranked by relevance across all providers.

Providers can implement the new RelevanceSearchProviderInterface,
which splits the former find() into two steps:

* findCandidates() returns lightweight Candidate objects, carrying
  only the provider class, a score and a reference to the record
* materialize() turns a page slice of candidates into ResultItem
  objects, in one batch per provider

PageRecordProvider, DatabaseRecordProvider and BackendModuleProvider
implement it. The two database providers select "uid" plus a score
column built by the new RelevanceScoreExpressionBuilder, an SQL
"CASE WHEN" expression with fixed buckets: exact label match (100),
label prefix (75), label match at a word boundary (50), label
substring (25) and a match in any other searchable field (10).
Sorting and limiting therefore happen in the database, and only the
records of the requested page are read in full.

Scores are floats, so an implementation can refine the buckets or
replace them with a continuous scheme such as BM25.

RelevanceScorer folds case and diacritics before comparing, by the
rules of @typo3/core/utility/text-normalizer, so "creme" scores
"Creme brulee" and "strasse" scores "Strasse". The SQL expression
compares by the collation of the connection instead, which is not
the same on every DBMS; the changelog entry says so.

SearchRepository ranks the candidates of all providers together
with the results of providers that still implement
SearchProviderInterface only. Those are scored in PHP by the new
RelevanceScorer, from the haystacks a provider declares via
ResultItem::setMatchHaystacks(), falling back to the item title
where a provider declares none. Their fetch is capped at 100 items
to bound the worst case, and their reported count is capped with
it, so pagination never offers a page the merge cannot fill.

Ties are broken by each provider's own position in its result set,
not by the order providers are registered in, so a score bucket
larger than one page is shared between them instead of being filled
by whichever provider comes first.

The walk skips entries until the page offset is reached and then
materializes the slice per provider, so the number of queries per
request follows the page size rather than the number of hits.

SearchRepository::find() returns a SearchResult now, holding the
paginator and the per-provider result counts. The counts reach the
client as "groupCounts".

In the user interface, the provider dropdown of the search form is
replaced by filter tabs above the result list, one per provider plus
"All". The chosen tab is submitted as the new "activeGroup" demand
property and restricts pagination to that provider. Since results
are ranked globally, the type headlines in the result list are gone,
and so are the search option items along with their persisted
session state.

Test this change

Run a command in your clone of the TYPO3 Core. Then try what the change does and vote on Verified in Gerrit. How to review a patch

Check out patch set 6
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/15/94015/6 && git checkout FETCH_HEAD
Cherry-pick onto main
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/15/94015/6 && git cherry-pick FETCH_HEAD

Review

  • Code review CR 0 Needs a vote
  • Verified V 0 Needs a vote
    • core-ci +1 CI

Merge conflicts 52

Issues 1

Files 33

Show 13 more files

Review log 813

  1. Benjamin Kott uploaded patch set 1 05/07/26, 08:49

  2. Benjamin Kott wrote 07/30/26, 07:29

    Unset private
  3. Benni Mack uploaded patch set 2 07/30/26, 14:05

  4. core-ci voted on patch set 2 V -1 07/30/26, 14:19 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/105698

  5. Benni Mack commented on patch set 2 08/10/26, 12:53

    Candidate.php:41 Unresolved

    we should switch to float if we want to go with BM25 for alternative implementations.

    RelevanceScorer.php:39 Unresolved

    if we want to get closer to BM25, we should return float in general

    ResultItem.php:156 Unresolved

    we could do a float here as well
  6. Benjamin Kott uploaded patch set 3 V -1 09/09/26, 12:32

  7. core-ci voted on patch set 3 V +1 09/09/26, 12:40 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/108177

  8. Benjamin Kott updated the commit message in patch set 4 V +1 09/09/26, 13:41

  9. core-ci voted on patch set 4 V +1 09/09/26, 13:49 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/108186

  10. Benni Mack uploaded patch set 5 V +1 11/11/26, 13:00

  11. core-ci voted on patch set 5 V +1 11/11/26, 13:09 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/114075

  12. Benni Mack uploaded patch set 6 V +1 11/19/26, 12:38

  13. core-ci voted on patch set 6 V +1 11/19/26, 12:46 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/115009