After you create a metadata index, you can query the metadata of one or more files by calling API operations of Intelligent Media Management (IMM). You can also query metadata by using field searches, fuzzy keyword searches, or natural language keyword searches. This topic describes how to query file metadata.
Prerequisites
A metadata index is created for your files based on your use scenario. For more information, see Create a metadata index.
Query methods
The following table describes the methods that you can use to query file metadata.
Method | Description |
Query the metadata of a single file | Call the GetFileMeta operation to query the metadata of a single file. |
Query the metadata of multiple files | Call the BatchGetFileMeta operation to call the metadata of multiple files at a time. |
Perform a simple query | Call the SimpleQuery operation to query files that meet the specified conditions and list metadata by field in a specific sorting order. You can also use nesting to perform complex queries and perform aggregation operations to collect statistics on and analyze the values of different fields. For a list of the supported fields and operators, see Supported fields and operators. |
Perform a fuzzy search | Call the FuzzyQuery operation to query files that match the specified string and list file metadata. IMM searches for the specified string within extracted metadata fields, such as the file name, label, path, or custom label. If one metadata field value of a file matches the specified string, all metadata of the file is returned. |
Perform a natural language keyword search | Call the SemanticQuery operation to query metadata in a dataset based on natural language keywords. The operation supports semantic searches based on the Labels, ProduceTime, and AddressLine fields. For example, to query the metadata of files that semantically relate to 'sky over Hangzhou,' you can specify 'Query=sky over Hangzhou' as the query condition. |
Query the metadata of a single file
Query the metadata of multiple files
Perform a simple query
Example 1
The following content provides the conditions of the query:
Project name: test-project
Dataset name: test-dataset
File type: image
Query result sorting: in the ascending order of file size
Maximum number of returned query results: 100
Example 2
The following content provides the conditions of the query:
Project name: test-project
Dataset name: test-dataset
File type: image
File size: greater than 10 MB
Custom labels (CustomLabels.category): Persons
Query result sorting: in the ascending order of file size
Maximum number of returned query results: 100
Example 3
The following content provides the conditions of the query:
Project name: test-project
Dataset name: test-dataset
File path: oss://test-bucket/
File size: greater than 10 MB
Labels (Labels.LabelName): "TV" or "Stereo"
Query result sorting: in the ascending order of file size
Maximum number of returned query results: 100
Example 4
The following content provides the conditions of the query:
Project name: test-project
Dataset name: test-dataset
File type: image
File size: greater than 10 MB
Custom labels (CustomLabels.category): Persons
Returned result: the total size of matched files
Example 5
The following content provides the conditions of the query:
Project name: test-project
Dataset name: test-dataset
File size: greater than 10 MB
Faces (Figures.Age and Figures.Gender): age and gender
Query result sorting: in the ascending order of file size
Maximum number of returned query results: 100
Example 6
The following content provides the conditions of the query:
Project name: test-project
Dataset name: test-dataset
File type: image
File size: greater than 10 MB
Custom labels (CustomLabels.category): existence
Returned result: the total size of matched files