You can use the ICU Collation Field instead of string: <fieldType name="sort" class="solr.ICUCollationField" locale="" numeric="true" strength="secondary" alternate="shifted" sortMissingLast="true" />
<dynamicField name="*_ans" type="sort" stored="false" /> <!-- ans = alpha-numeric sort --> This sorts numbers and letters correctly, as well as does Unicode folding, so 1,2,3...10...20, instead of 1,10...2,20...,3, and folds the characters so that ä,á, etc. are sorted as "a". https://solr.apache.org/guide/8_11/language-analysis.html#unicode-collation > On 1 Feb 2022, at 14:36, Markus Jelsma <[email protected]> wrote: > > Hello Sebastian, > > This the natural sort order, just look at an ASCII-table. If you want > charachters nicely bundled together you can either make a complicated > Comparator or CopyField the original string value to a analyzed Text field > that has a KeywordTokenizer, and an ASCIIFoldingFilter configured. > > Sort on that field, and do a secondary sort on the original field to take > care of the cases. > > Regards, > Markus > > Op di 1 feb. 2022 om 13:07 schreef Sebastian Riemer <[email protected]>: > >> I am using Solr 8.10 >> >> >> LITTERA Software & Consulting GmbH >> >> A-6060 Hall i.T., Haller Au 19a >> Telefon: +43 (0) 50 765 000, Fax: +43 (0) 50 765 118 >> Sitz: Hall in Tirol, eingetragen beim Handelsgericht Innsbruck, >> Firmenbuch-Nr. FN 295807k, geschäftsführender Gesellschafter: Albert >> Unterkircher, MSc >> >> D-80687 München, Landsberger Straße 155 >> Telefon: +49 (0) 89 919 29 122, Fax: +49 (0) 89 919 29 123 >> Sitz: München, eingetragen beim Amtsgericht München >> unter HRB 103698, Geschäftsführer: Albert Unterkircher >> E-Mail: [email protected] >> Homepage:www.littera.eu >> >> Diese Nachricht kann vertrauliche, nicht für die Veröffentlichung >> bestimmte und/oder rechtlich geschützte Informationen enthalten. Falls Sie >> nicht der beabsichtigte Empfänger sind, beachten Sie bitte, dass jegliche >> Veröffentlichung, Verbreitung oder Vervielfältigung dieser Nachricht >> strengstens untersagt ist. Sollten Sie diese Nachricht irrtümlich erhalten >> haben, informieren Sie bitte sofort den Absender durch Anruf oder >> Rücksendung der Nachricht und vernichten Sie diese. >> >> This communication may contain information that is legally privileged, >> confidential or exempt from disclosure. If you are not the intended >> recipient, please note that any dissemination, distribution or copying of >> this communication is strictly prohibited. Anyone who receives this >> message in error should notify the sender immediately by telephone or by >> return e-mail and delete this communication entirely from his or her >> computer. >> >> -----Ursprüngliche Nachricht----- >> Von: Sebastian Riemer <[email protected]> >> Gesendet: Dienstag, 1. Februar 2022 12:58 >> An: [email protected] >> Betreff: Customize sort-behaviour on solr.StrField for German language >> >> Hello, >> >> I have documents with family names in german language context. >> The field type is defined like this: <fieldType name="string" >> class="solr.StrField" sortMissingLast="true" /> >> >> When sorting by this family name, I get results ordered like that: >> >> Ascending order: >> 1. Bart >> 2. Otz >> 3. Ozzbourne >> 4. Zacharias >> 5. bariton >> 6. biene >> 7. burtsch >> 8. ozza >> 9. Ádele >> 10. Òle >> 11. Ônna >> 12. Ötz >> 13. ägnie >> 14. órthega >> >> So, the ordering is: >> >> 1. A-Z (Uppercase) >> 2. a-z (Lowercase) >> 3. Umlauts and special accents >> >> That ordering seems suprising to me, I'd prefer it like this: >> >> 1. aäàâ-z (Lowercase) >> 2. AÄÀÂ-Z (Uppercase) >> >> Or in other words, lowercase before uppercase, and Umlauts and Special >> accents after its "natural character". >> >> Here is the full query fort he above example: >> >> start=0 >> &rows=50 >> &fq=tenant_id:1 >> &fq=u_markedAsDeleted_b:false >> >> &fq={!tag%3Du_cg_customergroup_0}(((u_customerGroupMemberships_customergroup_cp_ts_ns:(24)))) >> &fq=u_id_cp_s:[*+TO+*]&q=*:* >> &facet=true >> &facet.missing=true >> &facet.sort=count >> &facet.mincount=1 >> &sort=u_familyName_cp_s+asc,u_userName_cp_s+desc >> >> &qf=u_userName_cp_s^20+u_displayName_cp_s^20++text^2+text_en+text_de+text_it >> &pf=u_userName_cp_s^100+u_displayName_cp_s^20++text^10 >> &mm=100%25 >> >> >> Could you please give me some direction which parts of the documentation I >> can study to learn about sorting and how to achieve a custom sorting? >> >> Thank you and best regards, >> >> Sebastian >> >>
