In Alfresco, we can configure our search subsystem to Solr.
During search we need to sort our result based on property. So here I would like to focus on sorting on property specifically when you define your custom property.
Sorting Search Results:
When you want to sort on specific property, you need to set “tokenised”. It should be set either “false” or “both”.
By default “tokenised” is set to “true” and when you try to sort your result, Solr will throw below error
2014-06-30 13:23:06,768 ERROR [solr.core.SolrCore] [http-8443-5] java.lang.UnsupportedOperationException: Ordering not supported for @custom:myTestProperty
Sorting on Date and Date Range Query:
As mentioned above, if you want to sort your result based on any property, here specifically for
d: datetime, you can either set its “tokenised” to “false” or “both”.
If you make your date property “tokenised” to “false” then soring will work but it will NOT allow you to search on range query.
This query won’t give you any result with “tokenised “to “false”:
@custom\:myTestDate:[2011-06-13 TO 2014-06-01]
So you need to set “Tokenised” to “both” so your sorting and range query both will work.
In some scenario, You need to sort your search result numerically for an example for d:int type of property.
If you set “Tokenised” to “false” for your numeric property then Solr will sort results in lexical order [same as your text property ex: cm:name] rather than numeric order.
So to sort your results numerically you need to make “Tokenised” to “both”.
In Lucene, you can sort result regardless of “Tokenised” setting. If you are moving your search sub-system from Lucene to Solr then you need to make sure for “Tokenised” settings.
Whenever you make any change in your content model, need to re-build indexes so you need to make sure for searching and sorting requirement in advance.