Sort fts-alfreco query results by custom field

cancel
Showing results for 
Search instead for 
Did you mean: 
superdh
Active Member

Sort fts-alfreco query results by custom field

Hello,

I use smart folders to query my files and everything works fine, with the following json code :

"nodes" : [{
   "id":"111",
   "name" : "...",
   "search" : {
      "language" : "fts-alfresco",
      "query" : "=ns:field1:'value' and =ns:field2:'value' and =ns:field3:'value'"
   }

}]

Now, I try to order the results by field4 but nothing works :

"nodes" : [{
   "id":"111",
   "name" : "...",
   "search" : {
      "language" : "fts-alfresco",
      "query" : "=ns:field1:'value' and =ns:field2:'value' and =ns:field3:'value'"
   },

   "sort" : [
      {"column" : "ns:field4"}
   ]

}]

I used https://docs.alfresco.com/5.0/references/API-JS-query.html to find the code... But i don't know if I can order my files by using fts-alfresco language. How can I solve this please ?

5 Replies
afaust
Master

Re: Sort fts-alfreco query results by custom field

Typically the sort column needs to be specified with an @ in front of the name. Also, make sure your custom field is indexed and uses either tokenisation mode "false" or "both" (unless you can guarantee your query will be executed by the DB).

superdh
Active Member

Re: Sort fts-alfreco query results by custom field

Thanks for you answer but it is still not working.

My property is the following : 

<property name="ns:title">
   <title>Title</title>
   <type>d:text</type>
   <mandatory>true</mandatory>
   <index enabled="true">
      <tokenised>false</tokenised>
      <facetable>false</facetable>
   </index>
</property>

I tried the following sorts : "@ns:title", "@{ns}title", "@{http://www.company.org/model/ns/content/1.0 }title"

What is the exact format expected ?

douglascrp
Advanced II

Re: Sort fts-alfreco query results by custom field

AFAIK, there is no "sort" property for the Smart Folder configuration file (Smart Folder Template syntax | Alfresco Documentation)

Besides that, I believe it would not make sense to have it, as the sort order will be defined by the Share's document library component.

Please, correct me if I am wrong.

afaust
Master

Re: Sort fts-alfreco query results by custom field

Right - I did not think of that. See https://docs.alfresco.com/5.2/concepts/sf-ref-template-guidance.html for details about the syntax.

superdh
Active Member

Re: Sort fts-alfreco query results by custom field

Thank you, I will stop to search for nothing !

The sort option for DocumentLibrary works well, I can see the sort option in the list

<config evaluator="string-compare" condition="DocumentLibrary">
   <sorting>
      <sort label="label">ns:field</sort>
   </sorting>
</config>