Restrict search to a specific site using REST API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2017 11:30 AM
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?
- Labels:
-
Alfresco Content Services
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-12-2017 04:48 AM
Add SITE:<sitename> to your query:
"query": "SITE:<sitename> ..."
or the folder to search within as "ANCESTOR":
"query": "ANCESTOR:\"workspace://SpacesStore/...\""
Regards,
Martin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-12-2017 06:37 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-12-2017 06:39 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-12-2017 06:43 AM
We tried that too e.g. 'my-first-site'. That didn't work either.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-12-2017 06:45 AM
I had testsite and it worked, maybe you have to put it in quotes when the string contains "-" :
"query":"SITE:\"my-first-site\""
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-12-2017 11:53 PM
That worked perfectly. Thanks Martin.
