For searching alfresco contents/folders, we have a couple of webscripts readily available which are exposed by alfresco out of the box.
We can search the contents or folders just by hitting the following search URLs and we can get the appropriate response which we can parse and
get the required metadata.
http://localhost:8080/alfresco/service/api/search/keyword.atom?q={searchTerms}&p={startPage?}&c={count?}&l={language?}
(In above url, you can pick keyword.atom, keyword.rss, keyword.html, keyword.portlet, anyone based on your response/parsing needs.)
Apart from this, there is one more OOTB search webscript used by alfresco:
http://localhost:8080/alfresco/service/slingshot/search?term={term?}&tag={tag?}&site={site?}&container={container?}&sort={sort?}&query={query?}&repo={repo?}
In this URL, there are a few parameters which are not exposed for passing parameters into.
You can look at those parameters by exploring the search.get.js file and further search.lib.js.
Here, you will find parameters like rootNode, maxResults, sort, pageSize, startIndex - which facilities specific folder level search, limiting the search
result, sorting, pagination, etc.
For someone who would like to search in a folder (lets say - Company Home > XYZ > MyFolder), can pick up the nodeRef of MyFolder and pass its value in the
rootNode parameter which would restrict the search inside MyFolder only.
Also, by default this webscript would conduct a search inside all the sites created in alfresco share. So you would also need to pass repo=true for conducting
search inside Company Home > XYZ > MyFolder; else the search would be conducted inside Company Home > Sites folder.
Example URL:
http://localhost:8080/alfresco/service/slingshot/search?term=alfresco&repo=true&pageSize=10&startIndex=0&maxResults=100&rootNode=workspace://SpacesStore/1bcef6d2-792d-4224-9f98-2438b93e76a5
Please note that the user who will call this webscript URL, should have atleast consumer (view) rights on the noderef that he is going to pass in the value of rootNode parameter.
If the nodeRef value he passes in rootNode parameter is something on which he doesnot have permissions, then
the search will return all the results that matches with the keyword (without checking any permission).
Also, if you are looking for all contents/folders inside a folder, then you can pass
"*" in the term parameter (i.e term=*) which will give all results (with permissions checked).
Thank you for going through the blog.
Hope this may be helpful to you.
We can search the contents or folders just by hitting the following search URLs and we can get the appropriate response which we can parse and
get the required metadata.
http://localhost:8080/alfresco/service/api/search/keyword.atom?q={searchTerms}&p={startPage?}&c={count?}&l={language?}
(In above url, you can pick keyword.atom, keyword.rss, keyword.html, keyword.portlet, anyone based on your response/parsing needs.)
Apart from this, there is one more OOTB search webscript used by alfresco:
http://localhost:8080/alfresco/service/slingshot/search?term={term?}&tag={tag?}&site={site?}&container={container?}&sort={sort?}&query={query?}&repo={repo?}
In this URL, there are a few parameters which are not exposed for passing parameters into.
You can look at those parameters by exploring the search.get.js file and further search.lib.js.
Here, you will find parameters like rootNode, maxResults, sort, pageSize, startIndex - which facilities specific folder level search, limiting the search
result, sorting, pagination, etc.
For someone who would like to search in a folder (lets say - Company Home > XYZ > MyFolder), can pick up the nodeRef of MyFolder and pass its value in the
rootNode parameter which would restrict the search inside MyFolder only.
Also, by default this webscript would conduct a search inside all the sites created in alfresco share. So you would also need to pass repo=true for conducting
search inside Company Home > XYZ > MyFolder; else the search would be conducted inside Company Home > Sites folder.
Example URL:
http://localhost:8080/alfresco/service/slingshot/search?term=alfresco&repo=true&pageSize=10&startIndex=0&maxResults=100&rootNode=workspace://SpacesStore/1bcef6d2-792d-4224-9f98-2438b93e76a5
Please note that the user who will call this webscript URL, should have atleast consumer (view) rights on the noderef that he is going to pass in the value of rootNode parameter.
If the nodeRef value he passes in rootNode parameter is something on which he doesnot have permissions, then
the search will return all the results that matches with the keyword (without checking any permission).
Also, if you are looking for all contents/folders inside a folder, then you can pass
"*" in the term parameter (i.e term=*) which will give all results (with permissions checked).
Thank you for going through the blog.
Hope this may be helpful to you.