AnsweredAssumed Answered

Sorting of Contents based on two fields

Question asked by chai on Jul 12, 2011
Latest reply on Jul 12, 2011 by chai
Hi,

I want to sort the contents from Alfresco based on two fields. Please note the below points:
1) The first field used here for sorting (content_date) has only date part and not time part.
    So if there are more than one content with same content_date, I want them to be sorted based on modified date.
2) Sorting based on first field (content_date) alone works fine.
3) Sorting based on second field (modified) alone also works fine.
4) Sorting based on both fields together doesn't seem to be working.

My code looks like this:

import org.alfresco.service.cmr.search.SearchParameters;
……

   SearchParameters searchParameters = new SearchParameters();
   searchParameters.setLanguage(SearchService.LANGUAGE_LUCENE);
   ….
   searchParameters.addSort("@{http://www.myModel.com}content_date", false);
   searchParameters.addSort("@{http://www.alfresco.org/model/content/1.0}modified", false);
   ….

If anyone has implemented this, please provide your inputs.

Thank you.

Outcomes