cancel
Showing results for 
Search instead for 
Did you mean: 

What is the sort field name for sorting on content size?

dgildeh
Champ in-the-making
Champ in-the-making
Hi,

I've got sorting happening on all the fields I want apart from file size. I'm using the sort column below:

@{http://www.alfresco.org/model/content/1.0}content.size

However, this is throwing an exception everytime it is set. According to the documentation I should be able to sort on the file size, my question is what is the correct field name to use to do this?

Thanks,

David
4 REPLIES 4

arunlf
Champ in-the-making
Champ in-the-making
Hi David,

Did you find a solution for this issue yet?
I am facing the same problem.  When I try to sort the result based on content size, I don't get any result.
However for "{http://www.alfresco.org/model/content/1.0}name" , "{http://www.alfresco.org/model/content/1.0}created" I do get results

Following is the piece of code that I am using on the Java End.


private NodeRef[] queryChildren(NodeRef parent, CMISTypesFilterEnum typesFilter, String sortBy, boolean order)
    {
        SearchParameters params = new SearchParameters();
        params.setLanguage(SearchService.LANGUAGE_LUCENE);
        params.addStore(parent.getStoreRef());
        QueryParameterDefinition parentDef = new QueryParameterDefImpl(PARAM_PARENT, nodeRefDataType, true, parent.toString());
        params.addQueryParameterDefinition(parentDef);
        QName sortField = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, sortBy);
   params.addSort("@" + sortField, order);

        if (typesFilter == CMISTypesFilterEnum.FOLDERS)
        {
            params.setQuery(LUCENE_QUERY_SHALLOW_FOLDERS);
        }
        else if (typesFilter == CMISTypesFilterEnum.DOCUMENTS)
        {
            params.setQuery(LUCENE_QUERY_SHALLOW_FILES);
        }

        ResultSet resultSet = null;
        try
        {
            resultSet = searchService.query(params);
            List<NodeRef> results = resultSet.getNodeRefs();
            NodeRef[] nodeRefs = new NodeRef[results.size()];
            return results.toArray(nodeRefs);
        }
        finally
        {
            if (resultSet != null) resultSet.close();
        }
    }

In the above code sortField ends up as "{http://www.alfresco.org/model/content/1.0}content.size"  when I pass sortBy parameter as content.size
I dont get any results for content.size.

Please let me know if you have found something for content.size issue.

I am running alfresco version Alfresco 3.0. However for this piece I have used some code from later versions.

Regards
Arun Furtado

dgildeh
Champ in-the-making
Champ in-the-making
Hi Arun,

Unfortunately I haven't had any reply to this in the forum so I've had to give up on it. If anyone knows the solution please let us know.

Thanks,

David

arunlf
Champ in-the-making
Champ in-the-making
Thanks David,

Probably this is related to the Alfresco issue http://issues.alfresco.com/jira/browse/ALF-3776
Not sure what changes were made to fix this issue.

Can anyone from Alfresco team let me know how I can track files/code that was changes for a given issue. In this case ALF-3776.
I am running Alfresco 3.0. So, would like to update my server with this change.

Thanks.
Arun Furtado

andy
Champ on-the-rise
Champ on-the-rise
Hi

Yes this bug fix will address the issue. The fix was made in 3.4.1 and so has not made it into a community version yet.

Andy