how to change community/collection sort order from name to short description

106 views
Skip to first unread message

cerva...@gmail.com

unread,
Mar 5, 2024, 2:37:21 AM3/5/24
to DSpace Technical Support
We have been developing dSpace based repositories for 12 years, but now we have a problem, we can’t solve.
This angular is brand new for us, thus we have to rewrite all our former changes we did formerly in dSpace both frontend and backend.
So, our Community/Collection structure and list should cover the institutional logic, not the strict alphabetical order.
It was easy to change until 6.x, where we changed the default sort field in CommunityServiceImpl.java and CollectionServiceImpl.java from dc.title, to dc.description.abstract and we hid the short description field in list, but wrote codes into it, according to our sort intentions.
But now, I can’t find a solution, neither changes in backend, nor in frontend files won’t help.
I have tried everthing, I have changed all dc.title field I found in ts and config files to dc.descrtiption.abstract, but nothing, I did the changes in java files written above.
Of course I rebuilt backend, frontend and restarted angular even I reindexed solr.
Do you have any idea, how to change?

ps: I even changed the /src/app/core/pagination/pagination.service.ts defaultSortOptions to dc.description.abstract but nothing!!!

László Jóbi

unread,
Jan 29, 2025, 7:23:00 AM1/29/25
to DSpace Technical Support

Hello, 

I encountered a similar issue, and I found the following solution that worked:

First, you need to add the custom sorting configuration to the discovery.xml file:

<bean id="sortDescriptionAbstract" class="org.dspace.discovery.configuration.DiscoverySortFieldConfiguration">
    <property name="metadataField" value="dc.description.abstract_sort"/>
    <property name="defaultSortOrder" value="asc"/>
</bean>

Next, modify the buildDocument() method in both CollectionIndexFactoryImpl.java and CommunityIndexFactoryImpl.java by adding the following line:

doc.addField("dc.description.abstract_sort", description_abstract);
This ensures that Solr properly indexes the field.

Then, update the findAll() method in the following classes:

CommunityRestRepository
CommunitySubcommunityLinkRepository
CommunityCollectionLinkRepository
Make sure to modify the sorting the original configuration (discoverQuery.setSortField("dc.title_sort", DiscoverQuery.SORT_ORDER.asc)) to this:
discoverQuery.setSortField("dc.description.abstract_sort", DiscoverQuery.SORT_ORDER.asc);

Finally, don’t forget to reindex DSpace to apply the changes:

[dspace]/bin/dspace index-discovery -b
After these changes, the sorting should work as expected on the community list page.

Hope this helps!

Laszlo
Reply all
Reply to author
Forward
0 new messages