Cloudinary allows access to two types of resource metadata (MD). The first type of metadata is the embedded metadata that an asset has and the second one is the structured metadata.
It's possible to search for assets based on either one of the MD types.
Types of Metadata
Embedded metadata is MD like EXIF or XMP which is integrally built in the asset. This is metadata that the asset itself would have before being uploaded to Cloudinary. For example, images taken using a mobile device would usually have a rotation angle embedded in the image file.
Structured metadata is a set of custom fields that you can define at the product environment level and assign to assets using Cloudinary. For each field you define, you can specify a field name, value type (string, number, date, list, etc), and other optional settings. You can read more about managing structured metadata
How to search for assets based on Metadata using the search API
It's possible to search for assets based on either embedded metadata or structured metadata using Cloudinary's search API
The search API uses query language to search assets and it is possible to build complex expressions to base the search on.
Searching using structured metadata requires using the `metadata` field in the search expression.
You would need to specify both the metadata field name and the value you would like to search by. Here are a few examples to get you started.
Search for assets that have a value in the structured metadata external_id `quantity_id`
metadata=quantity_id
Search for assets with a structured metadata external_id of `quantity_id` whose value is less than ten
metadata.quantity_id<10
Search for assets that do not have any value applied to the structured metadata external_id 'quantity_id'
-metadata=quantity_id
Search for assets in the folder 'products/sale' that have the structured metadata external_id 'quantity_id' whose value is greater than 5
folder:"products/sale" AND metadata.quantity_id>5
Search for assets in the folder 'products/sale', including any subfolders of 'sale', that do not have any value applied to the structured metadata external_id 'quantity_id'
folder:"products/sale/*" AND -metadata.quantity_id
You can see a full explanation and additional details on how to search using structured metadata in our documentation about search fields
Searching using embedded metadata is possible in using the search API as well. This type of search is available on Tier 2 of the search API which is available upon request for Advanced plans and higher. Note that tier 2 is provided at an extra cost.
In order to search using embedded metadata it's possible to use the `media_metadata` field of the search API. In order to search using embedded metadata, you would need to add the name of the metadata field.
An example of a search component for an embedded metadata field called license can be seen here:
media_metadata.license=a1s3d5f7a9s2d4f
You can read more detailed information on how to search using the API and using embedded metadata in our documentation
How to search for assets based on Metadata using the media library
In the media library, it's possible to search for assets using structured metadata that was previously created, and also by contextual MD that can be added.
In order to do so, you can go to the media library and click on the "advanced search" icon to the right of the search bar. Following that go to the "metadata" tab and choose the metadata field and value you want to search by.
The below video explains that in further detail:
Searching by embedded metadata is currently only possible from the global search bar. In order to do that go to the blue "menu" icon on the top left of the media library.
Then go to the preferences section and click to enable the option to "Include embedded metadata in global search results". Once the checkbox is enabled, click "save" on the bottom of the page.
The below video explains that in further details:
Enabling the option to search for embedded metadata currently allows searching for specific strings only on the global search bar.
It is on our roadmap to allow a more granular search of embedded metadata as well.
Comments
0 comments
Please sign in to leave a comment.