ext-solr icon indicating copy to clipboard operation
ext-solr copied to clipboard

[BUG] Facets orderBy defaults to "index" in 11.5+

Open baschny opened this issue 1 year ago • 4 comments

Describe the bug Updating from 11.2 to 11.5 (TYPO3 v10 to v11) we noticed the change in behaviour for the sorting of facets.

To Reproduce A setup like this:

        faceting {
            facets {
                categoryHierarchy {
                    field = category
                    type = hierarchy
                    operator = OR
                }

Expected behavior In 11.2 the default "sortBy" was "count".

In 11.5 even thou the documentation did not change, the default is now "index" (which sorts them by some random internal solr value?).

Solution was to add an explicit sortBy:

        faceting {
            facets {
                categoryHierarchy {
                    field = category
                    type = hierarchy
                    operator = OR
                    sortBy = count
                }

So we need to either change the documentation or find the cause of the change of behaviour.

Used versions (please complete the following information):

  • TYPO3 Version: v11.5
  • EXT:solr Version: 11.5.5
  • Used Apache Solr Version: (Docker): typo3solr/ext-solr:11.5
  • PHP Version: 8.1

baschny avatar Dec 05 '23 20:12 baschny

@baschny Thanks for reporting. Are you sure the "hierarchy"-facet sorting is the good example? IMHO the hierarchy should not be sorted at all.

dkd-kaehm avatar Dec 06 '23 08:12 dkd-kaehm

That is strange I can not reproduce that on solr-ddev-site 12.0/main

ddev start
ddev solr:enable news

Then index all news and pages and search for *:

https://solr-ddev-site.ddev.site/content-examples/form-elements/search?tx_solr%5Bq%5D=*

grafik

Please check other setting like faceting.sortBy

dkd-kaehm avatar Dec 06 '23 09:12 dkd-kaehm

Maybe its only in the hierary facet, but this is indeed our use-case. In this case we have a sys_category facet and want to have the categories with most documents on top:

11.2 11.5
without explicit sortBy = count
face-hierarchy Bildschirmfoto 2023-12-06 um 14 38 22

(the amount is different due to the upgrade not being with live data yet).

Debugging the generated solr query showed me the facet.sort being set to 'index'. In the code I dug up the method getForFacet where this might come from, but maybe someone which worked in that area would be faster in figuring out what could be wrong. If you need my assistance in debugging, please let me know.

baschny avatar Dec 06 '23 13:12 baschny

Debugging the generated solr query showed me the facet.sort being set to 'index'. In the code I dug up the method getForFacet where this might come from, but maybe someone which worked in that area would be faster in figuring out what could be wrong. If you need my assistance in debugging, please let me know.

Ouch, nice catch @baschny See: #3595

dkd-kaehm avatar Dec 06 '23 15:12 dkd-kaehm