How do I search for media with a given thesaurus value ?
Search on thesaurus value is made using the thesaurus id of the thesaurus value and the internal field name of the thesaurus.
You can retrieve them by browsing /api/dam/thesaurus-tree to find the id of the thesaurus field.
Once the thesaurus field found, existing thesaurus values can be retrieved through /api/dam/thesaurus-tree/{thesaurus_id}
For example if you are looking for 'Yellow' value in a thesaurus named 'color' , the associated id is in its representation :
{
"id": 2980,
"title": "Yellow",
"_links": {
"self": {
"href": "http://baobab.keepeek.com/api/dam/thesaurus-tree/916/children/2980"
},
"kpk:thesaurus": {
"href": "http://baobab.keepeek.com/api/dam/thesauruses/2980"
}
}
}
Once the id of thesaurus value known, you can use it in a search request :
GET /api/dam/search/media?fq=thesaurus:color:2980
If the thesaurus term is not a 'leaf' of the tree, and contains sub-terms, the above query will restrict search to media containing the thesaurus value. As for folders, sub-terms of thesaurus can also be looked for by appending subtree
to the thesaurus node id in the search request :
GET /api/dam/search/media?fq=thesaurus:color:2980 subtree
For example if the thesaurus node 'Yellow' contains sub-terms such as 'Bright yellow', 'Lemon yellow' or 'Corn yellow', the above query will return any media containing either 'Yellow' or 'Bright yellow' or 'Lemon yellow' or 'Corn yellow' in the 'color' thesaurus field.