#108307Search results are sorted the wrong way, e.g. ascending by rank_flag
Description
Indexed Search 13.4.20plugin.tx_indexedsearch.settings.defaultOptions.sortDesc = 1 leads to ascending order (the least relevant result comes first).
This is easily fixed via TypoScript by setting defaultOptions.sortDesc = 0. Therefore I assume it’s just a matter of exchanging ASC for DESC or vice versa at some point.
Reviews 4
Files 3
History 612
-
Garvin Hicking commented and changed status
NewNeeds Feedback <span data-processor="relativetime" data-value="2025-11-25T09:06:43+00:00" > 11/25/25, 09:06 </span> -
Monika Schneiders commented and changed attached sortDesc_0.png attached sortDesc_1_oben.png attached sortDesc_1_unten.png <span data-processor="relativetime" data-value="2025-11-25T10:44:50+00:00" > 11/25/25, 10:44 </span>
Vielleicht liegt das Problem auch woanders. In beiliegenden Screenshots sieht man nicht nur die beschriebene umgekehrte Sortierreihenfolge, sondern im Vergleich zwischen Bild 1 und 3 auch, dass das Ranking bei der Einstellung sortDesc=0 unerwartet deutlich kleiner als 100% ist.
Ansonsten wird die Suche hier mit Standardeinstellungen eingesetzt.
-
Ernesto Baschny commented <span data-processor="relativetime" data-value="2025-12-08T19:11:38+00:00" > 12/08/25, 19:11 </span>
Got the same problem. Indexedsearch in TYPO3 v12 behaved differently in the default setup, which is:
defaultOptions {
…
sortOrder = rank_flag
sortDesc = 1I think nobody ever configured indexed search to sort by something else than “ranking”. And “descending” seems to be the appropriate default.
But, due to two bugs (probably introduced when indexed search was migrated to Extbase some 10-12 years ago), it worked as we expect it:
1. IndexSearchRepository::getDescendingSortOrderFlag() – which processes this value – is misleading / buggy, since it returns
DESCin case thesortDesc=0and empty (defaultASC) in case ofsortDesc=1.2. Until TYPO3 v12, the sortDesc was not being used at all! Thus the value was empty, resulting in
DESCby default (which is what we want).Now since the bugfix #107780 (https://review.typo3.org/c/Packages/TYPO3.CMS/+/91173) suddenly the bug 2 was fixed, and now in v13 we see the change of behaviour – bug 1 now appearing.
Hot-Fix for current installations would be to change to `sortDesc = 0`.
Better yet would be to change the behaviour of
getDescendingSortOrderFlagso that it does what it’s name assumes that it does. In case ofsortDesc=1, sort byDESC, otherwise sort byASC.Either way, it will change the behavious – as it already happened between v12 and v13.
Ideas?
-
Marcel Marty commented <span data-processor="relativetime" data-value="2026-01-28T08:48:08+00:00" > 01/28/26, 08:48 </span>
We fixed that temporary with the following XCLASS in our site package:
sitepackage/Classes/XClass/IndexedSearch/Domain/Repository/IndexSearchRepository.php:
<?php declare(strict_types=1); namespace VENDOR\ExtensionName\XClass\IndexedSearch\Domain\Repository; use TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository as BaseIndexSearchRepository; /** * XClass to fix the inverted sorting logic in indexed_search */ class IndexSearchRepository extends BaseIndexSearchRepository { /** * Returns "DESC" or "ASC" depending on the settings of the incoming * highest/lowest result order (piVars['desc']) * * In the original class, the logic was inverted: * !$desc ? ' DESC' : '' * Which meant that if desc was true, it returned ASC, and if desc was false, it returned DESC. * * @param bool $inverse If TRUE, inverse the order which is defined by piVars['desc'] * @return string "DESC" or "ASC" */ protected function getDescendingSortOrderFlag(bool $inverse = false): string { $desc = $this->descendingSortOrderFlag; if ($inverse) { $desc = !$desc; } return $desc ? 'DESC' : 'ASC'; } }in ext_localconf.php:
// XClass for indexed_search to fix sorting logic $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][\TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository::class] = [ 'className' => \VENDOR\ExtensionName\XClass\IndexedSearch\Domain\Repository\IndexSearchRepository::class, ]; -
Gerrit Code Review pushed patch set 1 for main to change 94787 status
Needs FeedbackUnder Review <span data-processor="relativetime" data-value="2026-07-15T06:46:05+00:00" > 07/15/26, 06:46 </span> -
Gerrit Code Review pushed patch set 2 for main to change 94787 <span data-processor="relativetime" data-value="2026-07-15T07:56:56+00:00" > 07/15/26, 07:56 </span>
-
Gerrit Code Review pushed patch set 3 for main to change 94787 <span data-processor="relativetime" data-value="2026-07-15T08:38:33+00:00" > 07/15/26, 08:38 </span>
-
Gerrit Code Review pushed patch set 4 for main to change 94787 <span data-processor="relativetime" data-value="2026-07-17T14:46:39+00:00" > 07/17/26, 14:46 </span>
-
Gerrit Code Review pushed patch set 1 for 14.3 to change 94899 <span data-processor="relativetime" data-value="2026-07-23T11:04:05+00:00" > 07/23/26, 11:04 </span>
-
Gerrit Code Review pushed patch set 1 for 13.4 to change 94900 <span data-processor="relativetime" data-value="2026-07-23T11:04:13+00:00" > 07/23/26, 11:04 </span>
-
Tobias Wojtylak commented and changed status
Under ReviewResolved done0 %100 % <span data-processor="relativetime" data-value="2026-07-23T12:00:09+00:00" > 07/23/26, 12:00 </span>Applied in changeset commit:c0b6c146c10b3af86acd758d0349be263f99ab04.
-
Benni Mack changed status
ResolvedClosed <span data-processor="relativetime" data-value="2026-08-11T08:46:41+00:00" > 08/11/26, 08:46 </span>
Hm, but the query “select * from index_rel order by flags desc, freq desc” actually returns with descending order the highest value first, so that is the most important value first.
Can you describe this more in depth please?
The DESC sort order has been in indexed_search forever and from what I can gather it properly sorts by priority with most important items first for “rank_flag” sorting.