We are using Alfresco CE 5.2. Using the REST API for Search, we want to restrict the search to a particular site only. Going through the Search API details on the API explorer page, we did not find any details on how to restrict search to one site.
We also tried the following solution provided by someone else:
{
"query": {
"language": "afts",
"query": "=PARENT:<node ID> AND =name:'<search query>'"
}
}
However, this did not return any results for us.
Is there a way to use the REST API to search within a specific site or folder?
Add SITE:<sitename> to your query:
"query": "SITE:<sitename> ..."
or the folder to search within as "ANCESTOR":
"query": "ANCESTOR:\"workspace://SpacesStore/...\""
Regards,
Martin
The one with 'SITE' did not work for us.
When you say <sitename>, do I just mention the site name e.g. 'My First Site', or something else?
The 'ANCESTOR' one worked, though. Thanks.
the site name should be the "short name" or "id" of the site. The one that's also used in the url to the site.
We tried that too e.g. 'my-first-site'. That didn't work either.
I had testsite and it worked, maybe you have to put it in quotes when the string contains "-" :
"query":"SITE:\"my-first-site\""
That worked perfectly. Thanks Martin.
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.