09-24-2016 04:27 AM
Which parameters can be given to the alfresco/service/slingshot/search webscript?
I know about term=... and site=... and I am able to use them.
I know that there is also a parameter sort=... but I have no idea about how to fill it! Which sort options are possible?
Thanks a lot in advance!
Kind regards KingKong
09-26-2016 06:47 AM
use it like this sort=cm:name|true ( you should encode special character)
cm:name is the sort column which is mandatory
true means ascending or decending,it is optional, defaults to false
09-28-2016 04:36 AM
Thanks a lot for your answer.
It would be great to know which other parameters can be inserted sort by. I guess it would also be possible to sort by date or file size or something? What can be inserted for sort=...?
This would help me a lot!
And another question: the seach web script is doing full text seach, right? Or does it only search by name?
Thanks in advance!
Kind regards
KingKong
09-28-2016 09:12 AM
This webscript use "fts-alfresco" as query language ,so it can do both metadata search and full text search.
Yes it is possible to sort by other columns
if you want to search by file size or mimetype ,write it like this sort = .size|true or sort=.mimetype|true
if you want to search by other column ,just replace cm:name with the column name ,for example sort = cm:created|true
09-30-2016 03:27 AM
Thanks a lot for your answer. I will try that.
How can I differentiate between metadata and fulltext search? Is there also a parameter to hand over to the webscript?
Your help is really appreciated!
Kind regards
KingKong
09-30-2016 10:00 AM
By default, the webscript will search against the following fields:
cm:name cm:title cm:description ia:whatEvent ia:descriptionEvent lnk:title lnk:description TEXT TAG,these fields include TEXT field which is a shortcut for searching all properties of type content(full text search), other fields are metadata fields.
You can customize the template to add or remove fields if needed,you can also customize search fields through query parameter which is a json object.
09-30-2016 10:19 AM
Thanks a lot!
Again a question concerning calling the webscript. I tried several things now, but still didn't manage to sort as I like to.
alfresco/slingshot/search?term=*test*&sort=cm:name|false
According to what I understood, this should return everything that matches a search for *test*, ordered by name in descending order (because of false). Unfortunately, it does not return anything, I guess I'm still calling the script incorrectly.
On the other hand, the following statement seems to be working:
alfresco/slingshot/search?term=*test*&sort=created
It returns the search results ordered by creation date, but I cannot specify to have the result in ascending or descending order. As you said, it defaults to ascending which does not make sense in this case, because I want to have the 'newest' results first...
Any suggestions? Probably it's just a stupid mistake in calling the script as you proposed, but currently I'm not able to solve it...
Thanks again!
09-30-2016 10:56 AM
Following code is extract from webscript implementation that parse sort parameter ,you see sort direction is controlled by the optionally part that followed the sort field .
true = ascending, false = descending
// sort field - expecting field to in one of the following formats:
// - short QName form such as: cm:name
// - pseudo cm:content field starting with "." such as: .size
// - any other directly supported search field such as: TYPE
var sortColumns = [];
var sort = params.sort;
if (sort != null && sort.length != 0)
{
var asc = true;
var separator = sort.indexOf("|");
if (separator != -1)
{
asc = (sort.substring(separator + 1) == "true");
sort = sort.substring(0, separator);
}
var column;
if (sort.charAt(0) == '.')
{
// handle pseudo cm:content fields
column = "@{http://www.alfresco.org/model/content/1.0}content" + sort;
}
else if (sort.indexOf(":") != -1)
{
// handle attribute field sort
column = "@" + utils.longQName(sort);
}
else
{
// other sort types e.g. TYPE
column = sort;
}
sortColumns.push(
{
column: column,
ascending: asc
});
}
10-02-2016 07:52 AM
Thanks again, but it just does not want to work
...alfresco/slingshot/search?term=*test*&sort=cm:modified is working perfectly fine. It sorts ascending according to modification date.
But as soon as I add the search order (...alfresco/slingshot/search?term=*test*&sort=cm:modified|false or ...alfresco/slingshot/search?term=*test*&sort=cm:modified|true) it does not work at all. There is no answer to the request returned. Where is my mistake? I really don't get it... Could you just adapt my request if there is a simple error in it? Am I missing some characters or something?
Thank you so much for your patience.
10-04-2016 07:57 AM
I have tested this webscript in my environment ,it works fine,Following is a snapshot of search result .
Maybe it is a bug of your alfresco edition?
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.