As you probably know, folder and file nodes can be tagged. If you have a lot of nodes tagged it make sense to be able to find stuff based on these tags.
We can use the /search API to search for files and folders that have been tagged. The POST body looks like this:
{ "query": { "query": "+TAG:\"project-x\"", "language": "afts" } }
In this case I want to search for all folders and files that have been tagged project-x.
I have previously tagged a text file with this tag.
Here is how the call looks like, assuming that we have stored the query JSON data in a file called tag-query.json:
$ curl -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' --header 'Authorization: Basic VElDS0VUXzIxYzAzOWMxNjFjYzljMDNmNmNlMzAwYzAyMDY5YTQ2OTQwZmYzZmM=' --data-binary '@tag-query.json' 'http://localhost:8080/alfresco/api/-default-/public/search/versions/1/search' | jq % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 769 0 690 100 79 1869 214 --:--:-- --:--:-- --:--:-- 2084 { "list": { "pagination": { "count": 1, "hasMoreItems": false, "totalItems": 1, "skipCount": 0, "maxItems": 100 }, "context": { "consistency": { "lastTxId": 64 } }, "entries": [ { "entry": { "isFile": true, "createdByUser": { "id": "admin", "displayName": "Administrator" }, "modifiedAt": "2019-12-13T10:11:57.762+0000", "nodeType": "cm:content", "content": { "mimeType": "text/plain", "mimeTypeName": "Plain Text", "sizeInBytes": 18, "encoding": "UTF-8" }, "parentId": "d0ec1a36-0bda-40b9-8602-804b787f800e", "createdAt": "2019-12-02T13:31:35.619+0000", "isFolder": false, "search": { "score": 1 }, "modifiedByUser": { "id": "admin", "displayName": "Administrator" }, "name": "some-file.txt", "location": "nodes", "id": "7279b5c5-da55-4e98-8b12-72d33b90c810" } } ] } }
One response is expected as I only got one file tagged with project-x.