How to find content using API and metadata filters

Business Case:

KPI to be measured

Bookmark this resource Follow

Ask a question

Was this article helpful? 0 out of 0 found this helpful

THRON put at your disposal several ways to retrieve content quickly. Through Content API, you can obtain a content list filtered by specific metadata values.
You can use metadata filtering to find content with both findByProperties and search services:
  • When working with API findByProperties, you can filter content using metadata of type key with value, key, and classification.
  • When working with API search, you can filter metadata of type key with value, key, and classification. You can also perform fulltext search on text, key, and multi-language metadata:
    in this case, the search will return the list of all content that contain the searched string in at least one field among title, description, document’s body, tag’s name and metadata’s text. In this case, it is not possible to retrieve only the content that contain the searched string only in metadatas. Through the API search you can also filter content using other types of metadata.
There are different kinds of metadata in THRON that you can use to filter content, according to your specific needs or the information that the metadata represents (date, text, number, etc.).
Here below you can find the complete list of THRON metadata types you can use to filter content via API:
  • Metadata of type text with (key, string value, Option(LANG)). (consider the key of metadata)
    • Match operator: PREFIX or INTO or EQUAL
  • Metadata of type multi language (text) with (key, string value, Option(LANG)).
    • Match operator: PREFIX or INTO or EQUAL
  • Metadata of type key (text) with (key, string value, Option(LANG)).
    • Match operator: PREFIX or INTO or EQUAL
  • Metadata of type integer with (key, number)
    • Match operator: EQUAL or 'LOWER_THAN' or 'GREATER_THAN
  • Metadata of type decimal with (key, number)
    • Match operator: EQUAL' or 'LOWER_THAN' or 'GREATER_THAN
  • Metadata of type date with (key, date)
    • Match operator: EQUAL' or 'LOWER_THAN' or 'GREATER_THAN
  • Metadata of type color with (key, value)
  • Metadata of type boolean with (key, true/false)
  • Metadata of type multi-choice with (key, [string])
  • Metadata of type single choice with (key, string)
When you enrich contents with complex metadata, you will need to filter content according to them.
You can also filter content using inherited product information. Read the article First steps with Product API for more information.

[dropdown: How to filter content using key metadata]

Key metadata is a specific metadata built to perform optimized search on specific categories of content. For example, you might want to set a key metadata related to a specific product code in order to retrieve all content related to a specific product. In order to properly exploit this metadata for your content search activities, you need to know following characteristics:
  • it can be related only to one tag at a time;
  • maximum length is 100 characters;
  • it can not contain special characters;
  • it can not contain spaces;
  • it is not localized (monolingual).
Such constraints refer to the key of the metadata, the only constraint on their values is the length which must be lower than 100 characters.
To perform a search exploiting such metadata you will have to use a findByProperties request, providing the following JSON:
{ 
    "client": { 
        "clientId": "" 
    }, 
    "criteria": { 
        "linkedCategories": [ 
            "!__TRASH_" 
        ], 
        "imetadataKeyOp": { 
            "imetadata": [{ 
                "classificationId": "", 
                "key": "", 
                "value": "" 
            }] 
        } 
    } 
} 
You will be able to provide up to five key metadata simultaneously: the search will return all content with at least one of the provided metadata matching the value included in the request. Please be aware that both the key and the value of each metadata is case sensitive.

[/dropdown]

[dropdown:How to filter content using all the other types of metadata]

Here below you can find a series of use cases useful to understand how to usage all the other types of metadata in order to filter content via API.

 

Use case
You have a product that is available in different colors. You need to be able to find all the representative content for that product according to the available color variant.

 

Action
You have to define a STRING type metadata called "color" with all the possible colors separated by commas ("Black, Gold, Matt Black, White") as its value.

 

API search
{
	"criteria": {
		"imetadata": {
			"haveAll": [{
				"string": {
					"classificationId": "Your classification ID",
					"key": "color",
					"value": "Gold",
					"lang": [
						"EN"
					]
				}
			}]
		}
	},
	"responseOptions": {
		"returnDetailsFields": [
			"locales"
		],
		"resultsPageSize": 10,
		"sort": [{
			"lastUpdate": {
				"order": "asc"
			}
		}]
	}
}

 

Use case
You need to assign to your content a specific date, different from the creation or last update ones (e.g. date of shooting, date of event, etc.) in order to be able to filter content by this information.

 

Action
You have to define a DATE type metadata that contains the date that you want to associate with the content.

 

API search

{
	"criteria": {
		"imetadata": {
			"haveAll": [{
				" instant": {
					"classificationId": "Your classification ID",
					"key": "Shooting date",
					"value": "12/10/2021"
				}
			}]
		}
	},
	"responseOptions": {
		"returnDetailsFields": [
			"locales"
		],
		"resultsPageSize": 10,
		"sort": [{
			"lastUpdate": {
				"order": "asc"
			}
		}]
	}
}

 

Use case
You have a product that is available in different sizes. You need to be able to find all the representative content for that product according to the available size variant.

 

Action
You have to define a NUMBER type metadata called "size" and insert the product size.

 

API search
{
	"criteria": {
		"imetadata": {
			"haveAll": [{
				"integer": {
					"classificationId": " Your classification ID",
					"key": "size",
					"op": " EQUAL ",
					"value": 10
				}
			}]
		}
	},
	"responseOptions": {
		"returnDetailsFields": [
			"locales"
		],
		"resultsPageSize": 10,
		"sort": [{
			"lastUpdate": {
				"order": "asc"
			}
		}]
	}
}

 

Use case

 

You need to know which content in your THRON DAM PLATFORM are publishable or not, in order to manage content delivery according to your company guidelines.

 

Action
You have to define a TRUE/FALSE type metadata called "publish" which you can tick or untick.

 

API search
{
	"criteria": {
		"imetadata": {
			"haveAll": [{
				"boolean": {
					"classificationId": " Your classification ID",
					"key": " publish",
					"value": true
				}
			}]
		}
	},
	"responseOptions": {
		"returnDetailsFields": [
			"locales"
		],
		"resultsPageSize": 10,
		"sort": [{
			"lastUpdate": {
				"order": "asc"
			}
		}]
	}
}

[/dropdown]

[dropdown:How to use the INTO operator for partial match searches]

In case you need to find all the content which metadata partially match with a specific value, you can use the INTO operator. Here below you find a practical example of how to use it.
If you have:
Content1_Metadata:[ { 
"classification":"Classification ID"
"key":"colour"
"value":"red,blue,green"
}]
Content2_Metadata:[ { 
"classification":"Classification ID"
"key":"colour"
"value":"greenish,reddish"
}
{
"classification":"Classification ID"
"key":"size"
"value":"15,16,17,28,19"
}]
and you perform the search using the INTO operator, you will find:
  • if you search for colour "blue" you will find Content2
  • if you search for colour "," you will find Content1 and Content2
  • if you search for colour "red,blue" you will find Content1
  • if you search for colour "red" you will find Content1 and Content2
  • if you search for colour "ed,bl" you will find Content1
  • if you search for colour "reddish" you will find Content2
  • if you search for size "14" you will find Content2
  • if you search for size "1" you will find Content2
  • if you search for size "6" you will find Content2
  • if you search for size "16,17" you will find Content2
  • if you search for size "16 28" you will find nothing
  • if you search for size "17,16" you will find nothing
  • if you search for size "red" you will find nothing.

[/dropdown]

Was this article helpful?
0 out of 0 found this helpful

Have any question?

Open a ticket
Comments