cancel
Showing results for 
Search instead for 
Did you mean: 

Web-Script search - sort the search by custom content fields

wmay
Champ in-the-making
Champ in-the-making
Is it possible to use the Web-script search to perform a search and to get back the result sorted by custom content fields ? We only where able to run such a search and to sort the result by the "Standard fields" but not to sort by own defined custom content fields.

e.g. With the Share search i can select by which field the sort of the search result should performed - but is it possible to configure it to be able to select there and sort by custom content field or only by these standard fields ?

Is there any way to do this? What has to be done to be able to search and to get back a sorted list using custom fields.

This would be an important feature special when there are a large number of results. as far as i know there are also restrictions with the lucene search to get back "all" hits / documents from the repository - when there is no sorting and i get only back e.g. 250 hits from e.g. 10.000 possible results - i never know what i get back and so i maybe can not find my documents what is search for.

Thank you for your comments and help
4 REPLIES 4

openpj
Elite Collaborator
Elite Collaborator
Yes, but you should create your own custom WebScript that can use your custom fields to do what you want.
Using Freemarker you can set the specific custom field used to order results:

<#list companyhome.childrenByLuceneSearch["TEXT:alfresco* AND TEXT:tutorial*"]?sort_by([custom:yourCustomField]) as child>


</#list>
Hope this helps.

ivanatap
Champ in-the-making
Champ in-the-making
Hi,

I did my search like this:

 <#list companyhome.childrenByLuceneSearch["

                            +(@cm\\:modifier:\"${person.properties.userName}\"

                             OR

                            @cm\\:creator:\"${person.properties.userName}\")

                  +PATH:\".//*\"
                  
                  "]?sort_by([cm:modified]) as child>
</#list>

But, this doesn't work. Actually, this part does not work: ?sort_by([cm:modified])
Could anyone tells me where I made a mistake?

Thanks

openpj
Elite Collaborator
Elite Collaborator
Try to use the following:
sort_by(["cm:modified"])
Hope this helps.

ivanatap
Champ in-the-making
Champ in-the-making
Hi OpenPj,

Thanks for the quick answer.
I tried what you suggest, but than I got this error: 

Error during processing of the template '?sort_by(…) failed at sequence index 0: The "cm:modified" subvariable was not found.'. Please contact your system administrator.