Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@robmint
Last active February 17, 2016 02:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robmint/2f08b96d41ffff214087 to your computer and use it in GitHub Desktop.
Save robmint/2f08b96d41ffff214087 to your computer and use it in GitHub Desktop.
Adding custom fields to a Solr schema to enable sorting and grouping
<!-- typical filesystem location ../config/spring/api/discovery.xml -->
<!-- sort filters for the discovery search-->
<property name="searchSortConfiguration">
<bean class="org.dspace.discovery.configuration.DiscoverySortConfiguration">
<property name="defaultSortOrder" value="desc"/>
<property name="sortFields">
<list>
<ref bean="sortTitle" />
<ref bean="sortDateIssued" />
<ref bean="sortSomeField" />
</list>
</property>
</bean>
</property>
<!-- followed by the definitions of the properties later in the saem file -->
<!--Sort properties-->
<bean id="sortTitle" class="org.dspace.discovery.configuration.DiscoverySortFieldConfiguration">
<!-- definition below defaults to sort by alpha -->
<property name="metadataField" value="dc.title"/>
</bean>
<bean id="sortDateIssued" class="org.dspace.discovery.configuration.DiscoverySortFieldConfiguration">
<!-- in this case we want to sort by date, so that is specified explicitly -->
<property name="metadataField" value="dc.date.issued"/>
<property name="type" value="date"/>
</bean>
<bean id="sortSomeField" class="org.dspace.discovery.configuration.DiscoverySortFieldConfiguration">
<!-- here we explicitly type the field as an integer -->
<property name="metadataField" value="dc.some.field"/>
<property name="type" value="integer"/>
</bean>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment