ext-solr
ext-solr copied to clipboard
[BUG] Facets orderBy defaults to "index" in 11.5+
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 Thanks for reporting. Are you sure the "hierarchy"-facet sorting is the good example? IMHO the hierarchy should not be sorted at all.
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=*
Please check other setting like faceting.sortBy
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 |
|---|---|
(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.
Debugging the generated solr query showed me the
facet.sortbeing set to'index'. In the code I dug up the methodgetForFacetwhere 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