Queries objects that meet specific conditions and lists information about the objects based on specific fields and sorting methods. You can also use nested queries to perform complex queries and perform aggregate operations to collect and analyze the values of different fields.
Usage notes
To query objects that meet specific conditions, you must have the oss:DoMetaQuery
permission. For more information, see Attach a custom policy to a RAM user.
Request syntax
MetaSearch
POST /?metaQuery&comp=query&mode=basic HTTP/1.1
Host: BucketName.oss-cn-hangzhou.aliyuncs.com
Date: GMT Date
Authorization: SignatureValue
<?xml version="1.0" encoding="UTF-8"?>
<MetaQuery>
<NextToken></NextToken>
<MaxResults>5</MaxResults>
<Query>{"Field": "Size","Value": "1048576","Operation": "gt"}</Query>
<Sort>Size</Sort>
<Order>asc</Order>
<Aggregations>
<Aggregation>
<Field>Size</Field>
<Operation>sum</Operation>
</Aggregation>
<Aggregation>
<Field>Size</Field>
<Operation>max</Operation>
</Aggregation>
</Aggregations>
</MetaQuery>
AISearch
POST /?metaQuery&comp=query&mode=semantic HTTP/1.1
Host: BucketName.oss-cn-hangzhou.aliyuncs.com
Date: GMT Date
Authorization: SignatureValue
<?xml version="1.0" encoding="UTF-8"?>
<MetaQuery>
<MaxResults>99</MaxResults>
<Query>Overlook the snow-covered forest</Query>
<MediaTypes>
<MediaType>image</MediaType>
</MediaTypes>
<SimpleQuery>{"Operation":"gt", "Field": "Size", "Value": "30"}</SimpleQuery>
</MetaQuery>
Request headers
All headers in a DescribeRegions request are common request headers. For more information, see Common request headers.
Request elements
MetaSearch
Element | Type | Required | Example | Description |
mode | String | Yes | basic | Specifies that MetaSearch is used to query objects. |
MetaQuery | Container | Yes | N/A | The container in which you want to store the query conditions. Child nodes: NextToken, MaxResults, Query, Sort, Order, and Aggregations |
NextToken | String | No | MTIzNDU2Nzg6aW1tdGVzdDpleGFtcGxlYnVja2V0OmRhdGFzZXQwMDE6b3NzOi8vZXhhbXBsZWJ1Y2tldC9zYW1wbGVvYmplY3QxLmpw**** | The token that is used for the next query when the total number of objects exceeds the value of MaxResults. The object information is returned in alphabetical order starting from the value of NextToken. The first time you call this operation, set this element to null. Parent nodes: MetaQuery |
MaxResults | Integer | No | 5 | The maximum number of objects to return. Valid values: 0 to 100. If this parameter is not set or is set to 0, up to 100 objects are returned. Parent nodes: MetaQuery |
Query | String | Yes | {"Field": "Size","Value": "1048576","Operation": "gt"} | The query conditions. A query condition includes the following elements:
For more information, see Examples. Parent nodes: MetaQuery |
Sort | String | No | Size | The field based on which you want to sort the query results. For more information, see Appendix: Fields and operators supported in MetaSearch. Parent nodes: MetaQuery |
Order | String | No | asc | The method that you want to use to sort the query results. Valid values:
Parent nodes: MetaQuery |
Aggregations | Container | No | N/A | The container in which you want to store the information about aggregate operations. Child nodes: Aggregation Parent nodes: MetaQuery |
Aggregation | Container | No | N/A | The container in which you want to store the information about a single aggregate operation. Child nodes: Field and Operation Parent nodes: Aggregations |
Field | String | No | Size | The name of the field. For more information about the supported fields and the operators supported by the fields, see Appendix: Fields and operators supported in MetaSearch. Parent nodes: Aggregation |
Operation | String | No | sum | The operator for aggregate operations. Valid values:
Parent nodes: Aggregation |
AISearch
Element | Type | Required | Example | Description |
mode | String | Yes | semantic | Specifies that AISearch is used to query objects. |
MetaQuery | Container | Yes | N/A | The container in which you want to store the query conditions. Child nodes: MaxResults, Query, MediaTypes, and SimpleQuery |
MaxResults | Integer | No | 5 | The maximum number of objects to return. Valid values: 0 to 100. If this parameter is not set or is set to 0, up to 100 objects are returned. Parent nodes: MetaQuery |
Query | String | Yes | Overlook the snow-covered forest | The semantic content that you want to use to query objects. Parent nodes: MetaQuery |
MediaTypes | Container | Yes | N/A | The multimedia metadata conditions. Parent nodes: MetaQuery |
MediaType | String | Yes | image | The type of multimedia that you want to query. Valid values:
Parent nodes: MediaTypes |
SimpleQuery | String | No | {"Operation":"gt", "Field": "Size", "Value": "30"} | The query conditions. A query condition includes the following elements:
Parent nodes: MetaQuery |
Response headers
All headers in the response to a DescribeRegions request are common response headers. For more information, see Common response headers.
Response elements
MetaSearch
Element | Type | Example | Description |
MetaQuery | Container | N/A | The container in which the query results are stored. Child nodes: NextToken, Files, and Aggregations |
NextToken | String | MTIzNDU2Nzg6aW1tdGVzdDpleGFtcGxlYnVja2V0OmRhdGFzZXQwMDE6b3NzOi8vZXhhbXBsZWJ1Y2tldC9zYW1wbGVvYmplY3QxLmpw**** | The token that is used for the next query when the total number of objects exceeds the value of MaxResults. The value of NextToken is used to return the unreturned results in the next request. A value is returned for this element only when not all objects are returned. Parent nodes: MetaQuery |
Files | Container | N/A | The container in which the information about objects is stored. Child nodes: File Parent nodes: MetaQuery |
File | Container | N/A | The container in which the information about a single object is stored. Child nodes: Filename, Size, FileModifiedTime, OSSObjectType, OSSStorageClass, ObjectACL, ETag, OSSTaggingCount, OSSTagging, OSSUserMeta, OSSCRC64, and ServerSideEncryption Parent nodes: Files |
Filename | String | exampleobject.txt | The full path of the object. Parent nodes: File |
Size | Integer | 120 | The size of the object. Unit: bytes. Parent nodes: File |
FileModifiedTime | String | 2021-06-29T15:04:05.000000000Z07:00 | The time when the object was last modified. The value follows the RFC 3339 standard. Parent nodes: File |
OSSObjectType | String | Normal | The type of the object. Valid values:
Parent nodes: File |
OSSStorageClass | String | Standard | The storage class of the object. Valid values:
Parent nodes: File |
ObjectACL | String | default | The access control list (ACL) of the object. Valid values:
Parent nodes: File |
ETag | String | "fba9dede5f27731c9771645a3986****" | The ETag that is generated when the object is created. ETags are used to identify the content of objects.
Note The ETag value of an object can be used to check whether the object content is modified. We recommend that you use the MD5 hash of an object instead of the ETag value of the object to verify data integrity. Parent nodes: File |
OSSTaggingCount | Integer | 2 | The number of tags of the object. Parent nodes: File |
OSSTagging | Container | N/A | The container in which the information about the object tags is stored. Child nodes: Tagging Parent nodes: File |
Tagging | Container | N/A | The container in which the information about a single object tag is stored. Child nodes: Key and Value Parent nodes: OSSTagging |
Key | String | owner | The key of the tag or user metadata. User metadata must be prefixed with Parent nodes: Tagging and UserMeta |
Value | String | John | The value of the tag or user metadata. Parent nodes: Tagging and UserMeta |
OSSUserMeta | Container | N/A | The container in which the user metadata is stored. Child nodes: UserMeta Parent nodes: File |
UserMeta | Container | N/A | The container in which a piece of user metadata is stored. Child nodes: Key and Value Parent nodes: OSSUserMeta |
OSSCRC64 | String | 4858A48BD1466884 | The CRC-64 value of the object. This value is calculated based on the ECMA-182 standard. |
ServerSideEncryption | String | AES256 | The server-side encryption algorithm that OSS uses to encrypt an object when you create the object. Valid value: AES256. Parent nodes: File |
ServerSideEncryptionCustomerAlgorithm | String | SM4 | The algorithm that is used to encrypt the object on a local client. Parent nodes: File |
Aggregations | Container | N/A | The container in which you want to store the information about aggregate operations. Child nodes: Field, Operation, Operation, Value, and Groups Parent nodes: MetaQuery |
Field | String | Size | The name of the field. Parent nodes: Aggregations |
Operation | String | sum | The operator for the aggregate operation. Parent nodes: Aggregations |
Value | Floating-point | 200 | The result of the aggregate operation. Parent nodes: Aggregations |
Groups | Container | N/A | The grouped aggregations. Child nodes: Value and Count Parent nodes: Aggregations |
Value | String | 100 | The value for the grouped aggregation. Parent nodes: Groups |
Count | Integer | 5 | The number of results in the grouped aggregation. Parent nodes: Groups |
AISearch
Element | Type | Example | Description |
MetaQuery | Container | N/A | The container in which the query results are stored. Child nodes: Files |
Files | Array | N/A | The list of object information. Child nodes: File Parent nodes: MetaQuery |
File | Container | N/A | The information about a single object. Parent nodes: Files |
URI | String | oss://examplebucket/test-object.jpg | The full path of the object. Parent nodes: File |
Filename | String | exampleobject.txt | The name of the object. Parent nodes: File |
Size | Integer | 120 | The size of the object. Unit: bytes. Parent nodes: File |
ObjectACL | String | default | The ACL of the object. Valid values:
Parent nodes: File |
FileModifiedTime | String | 2021-06-29T15:04:05.000000000Z07:00 | The time when the object was last modified. The value follows the RFC 3339 standard. Parent nodes: File |
ServerSideEncryption | String | AES256 | The server-side encryption algorithm that OSS uses to encrypt an object when you create the object. Valid value: AES256. Parent nodes: File |
ServerSideEncryptionCustomerAlgorithm | String | SM4 | The algorithm that is used to encrypt the object on a local client. Parent nodes: File |
ETag | String | "fba9dede5f27731c9771645a3986****" | The ETag that is generated when the object is created. ETags are used to identify the content of objects.
Note The ETag value of an object can be used to check whether the object content is modified. We recommend that you use the MD5 hash of an object instead of the ETag value of the object to verify data integrity. Parent nodes: File |
OSSCRC64 | String | 4858A48BD1466884 | The CRC-64 value of the object. This value is calculated based on the ECMA-182 standard. Parent nodes: File |
ProduceTime | String | 2021-06-29T14:50:13.011643661+08:00 | The time when the image or video was taken. Parent nodes: File |
ContentType | String | image/jpeg | The Multipurpose Internet Mail Extensions (MIME) type of the object. Parent nodes: File |
MediaType | String | image | The type of multimedia. Parent nodes: File |
LatLong | String | 30.134390,120.074997 | The longitude and latitude information. Parent nodes: File |
Title | String | test | The title of the object. Parent nodes: File |
OSSExpiration | String | 2124-12-01T12:00:00.000Z | The time when the object expires. Parent nodes: File |
AccessControlAllowOrigin | String | The origins allowed in cross-origin requests. Parent nodes: File | |
AccessControlRequestMethod | String | PUT | The cross-origin request methods that are allowed. Parent nodes: File |
ServerSideDataEncryption | String | SM4 | The algorithm used to encrypt objects. Parent nodes: File |
ServerSideEncryptionKeyId | String | 9468da86-3509-4f8d-a61e-6eab1eac**** | The ID of the customer master key (CMK) that is managed by Key Management Service (KMS). Parent nodes: File |
CacheControl | String | no-cache | The web page caching behavior that is performed when the object is downloaded. Parent nodes: File |
ContentDisposition | String | attachment; filename =test.jpg | The name of the object when it is downloaded. Parent nodes: File |
ContentEncoding | String | UTF-8 | The content encoding format of the object when the object is downloaded. Parent nodes: File |
ContentLanguage | String | zh-CN | The language of the object content. Parent nodes: File |
ImageHeight | Integer | 500 | The height of the image. Unit: pixel. Parent nodes: File |
ImageWidth | Integer | 270 | The width of the image. Unit: pixel. Parent nodes: File |
VideoWidth | Integer | 1080 | The width of the video image. Unit: pixel. Parent nodes: File |
VideoHeight | Integer | 1920 | The height of the video image. Unit: pixel. Parent nodes: File |
VideoStreams | Array | N/A | The list of video streams. Parent nodes: File |
VideoStream | Container | N/A | The video stream. Parent nodes: VideoStreams |
CodecName | String | h264 | The abbreviated name of the codec. Parent nodes: VideoStream |
Language | String | en | The language used in the video stream. The value follows the BCP 47 format. Parent nodes: VideoStream |
Bitrate | Integer | 5407765 | The bitrate. Unit: bit/s. Parent nodes: VideoStream |
FrameRate | String | 25/1 | The frame rate of the video stream. Parent nodes: VideoStream |
StartTime | Double-precision floating-point | 0.000000 | The start time of the video stream. Unit: seconds. Parent nodes: VideoStream |
Duration | Double-precision floating-point | 22.88 | The duration of the video stream. Unit: seconds. Parent nodes: VideoStream |
FrameCount | Integer | 572 | The number of video frames. Parent nodes: VideoStream |
BitDepth | Integer | 8 | The bit depth. Parent nodes: VideoStream |
PixelFormat | String | yuv420p | The pixel format of the video stream. Parent nodes: VideoStream |
ColorSpace | String | bt709 | The color space. Parent nodes: VideoStream |
Height | Integer | 720 | The image height of the video stream. Unit: pixel. Parent nodes: VideoStream |
Width | Integer | 1280 | The image width of the video stream. Unit: pixels. Parent nodes: VideoStream |
AudioStreams | Array | N/A | The list of audio streams. Parent nodes: File |
AudioStream | Container | N/A | The audio stream. Parent nodes: AudioStreams |
CodecName | String | aac | The abbreviated name of the codec. Parent nodes: AudioStream |
Bitrate | Integer | 320087 | The bitrate. Unit: bit/s. Parent nodes: AudioStream |
SampleRate | Integer | 48000 | The sampling rate. Unit: Hz. Parent nodes: AudioStream |
StartTime | Double-precision floating-point | 0.0235 | The start time of the audio stream in seconds. Parent nodes: AudioStream |
Duration | Double-precision floating-point | 3.690667 | The duration of the audio stream in seconds. Parent nodes: AudioStream |
Channels | Integer | 2 | The number of sound channels. Parent nodes: AudioStream |
Language | String | en | The language used in the audio stream. The value follows the BCP 47 format. Parent nodes: AudioStream |
Subtitles | Array | N/A | The list of subtitle streams. Parent nodes: File |
Subtitle | Container | N/A | The subtitle stream. Parent nodes: Subtitles |
CodecName | String | mov_text | The abbreviated name of the codec. Parent nodes: Subtitle |
Language | String | en | The language of the subtitle. The value follows the BCP 47 format. Parent nodes: Subtitle |
StartTime | Double-precision floating-point | 0.000000 | The start time of the subtitle stream in seconds. Parent nodes: Subtitle |
Duration | Double-precision floating-point | 71.378 | The duration of the subtitle stream in seconds. Parent nodes: Subtitle |
Bitrate | Integer | 13091201 | The bitrate. Unit: bit/s. Parent nodes: File |
Artist | String | Jane | The artist. Parent nodes: File |
AlbumArtist | String | Jenny | The singer. Parent nodes: File |
Composer | String | Jane | The composer. Parent nodes: File |
Performer | String | Jane | The player. Parent nodes: File |
Album | String | FirstAlbum | The album. Parent nodes: File |
Duration | Double-precision floating-point | 15.263000 | The total duration of the video. Unit: seconds. Parent nodes: File |
Addresses | Array | N/A | The addresses. Parent nodes: File |
Address | Container | N/A | The address. Parent nodes: Addresses |
AddressLine | String | No.969, Wenyi West Road, Yuhang District, Hangzhou, Zhejiang, China | The full address. Parent nodes: Address |
City | String | Hangzhou | The city. Parent nodes: Address |
District | String | Yuhang District | The district. Parent nodes: Address |
Language | String | zh-Hans | The language of the address. The value follows the BCP 47 format. Parent nodes: Address |
Province | String | Zhejiang | The province. Parent nodes: Address |
Township | String | Wenyi West Road | The street. Parent nodes: Address |
OSSObjectType | String | Normal | The type of the object. Parent nodes: File |
OSSStorageClass | String | Standard | The storage class of the object. Parent nodes: File |
OSSTaggingCount | Integer | 2 | The number of tags of the object. Parent nodes: File |
OSSTagging | Array | N/A | The information about the tags. Child nodes: Tagging Parent nodes: File |
Tagging | Container | N/A | The container in which the information about a single object tag is stored. Child nodes: Key and Value Parent nodes: OSSTagging |
Key | String | owner | The key of the tag. Parent nodes: Tagging |
Value | String | John | The value of the tag. Parent nodes: Tagging |
OSSUserMeta | Array | N/A | The information about user metadata. Child nodes: UserMeta Parent nodes: File |
UserMeta | Container | N/A | The container in which a piece of user metadata is stored. Child nodes: Key and Value Parent nodes: OSSUserMeta |
Key | String | owner | The key of the user metadata. Parent nodes: Tagging |
Value | String | John | The value of the user metadata. Parent nodes: Tagging |
Examples
Sample requests
MetaSearch
POST /?metaQuery&comp=query&mode=basic HTTP/1.1
Host: BucketName.oss-cn-hangzhou.aliyuncs.com
Date: GMT Date
Authorization: SignatureValue
<?xml version="1.0" encoding="UTF-8"?>
<MetaQuery>
<NextToken></NextToken>
<MaxResults>5</MaxResults>
<Query>{"Field": "Size","Value": "1048576","Operation": "gt"}</Query>
<Sort>Size</Sort>
<Order>asc</Order>
<Aggregations>
<Aggregation>
<Field>Size</Field>
<Operation>sum</Operation>
</Aggregation>
<Aggregation>
<Field>Size</Field>
<Operation>max</Operation>
</Aggregation>
</Aggregations>
</MetaQuery>
AISearch
POST /?metaQuery&comp=query&mode=semantic HTTP/1.1
Host: BucketName.oss-cn-hangzhou.aliyuncs.com
Date: Date: Thu, 12 Sep 2024 13:08:38 GMT
Authorization: SignatureValue
<?xml version="1.0" encoding="UTF-8"?>
<MetaQuery>
<MaxResults>99</MaxResults>
<Query>Overlook the snow-covered forest</Query> // This parameter is required.
<MediaTypes>
<MediaType>image</MediaType>
</MediaTypes>
// SimpleQuery is equivalent to the Query field in Simple mode.
<SimpleQuery>{"Operation":"gt", "Field": "Size", "Value": "30"}</SimpleQuery>
</MetaQuery>
Sample responses
MetaSearch
HTTP/1.1 200 OK
x-oss-request-id: 5C1B138A109F4E405B2D****
Date: Mon, 26 Jul 2021 13:08:38 GMT
Content-Length: 118
Content-Type: application/xml
Connection: keep-alive
Server: AliyunOSS
<?xml version="1.0" encoding="UTF-8"?>
<MetaQuery>
<NextToken>MTIzNDU2Nzg6aW1tdGVzdDpleGFtcGxlYnVja2V0OmRhdGFzZXQwMDE6b3NzOi8vZXhhbXBsZWJ1Y2tldC9zYW1wbGVvYmplY3QxLmpw****</NextToken>
<Files>
<File>
<Filename>exampleobject.txt</Filename>
<Size>120</Size>
<FileModifiedTime>2021-06-29T15:04:05.000000000Z07:00</FileModifiedTime>
<OSSObjectType>Normal</OSSObjectType>
<OSSStorageClass>Standard</OSSStorageClass>
<ObjectACL>default</ObjectACL>
<ETag>"fba9dede5f27731c9771645a3986****"</ETag>
<OSSCRC64>4858A48BD1466884</OSSCRC64>
<OSSTaggingCount>2</OSSTaggingCount>
<OSSTagging>
<Tagging>
<Key>owner</Key>
<Value>John</Value>
</Tagging>
<Tagging>
<Key>type</Key>
<Value>document</Value>
</Tagging>
</OSSTagging>
<OSSUserMeta>
<UserMeta>
<Key>x-oss-meta-location</Key>
<Value>hangzhou</Value>
</UserMeta>
</OSSUserMeta>
</File>
</Files>
</MetaQuery>
AISearch
HTTP/1.1 200 OK
x-oss-request-id: 5C1B138A109F4E405B2D****
Date: Thu, 12 Sep 2024 13:08:38 GMT
Content-Length: 118
Content-Type: application/xml
Connection: keep-alive
Server: AliyunOSS
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<MetaQuery>
<Files>
<File>
<URI>oss://examplebucket/test-object.jpg</URI>
<Filename>sampleobject.jpg</Filename>
<Size>1000</Size>
<ObjectACL>default</ObjectACL>
<FileModifiedTime>2021-06-29T14:50:14.011643661+08:00</FileModifiedTime>
<ServerSideEncryption>AES256</ServerSideEncryption>
<ServerSideEncryptionCustomerAlgorithm>SM4</ServerSideEncryptionCustomerAlgorithm>
<ETag>\"1D9C280A7C4F67F7EF873E28449****\"</ETag>
<OSSCRC64>559890638950338001</OSSCRC64>
<ProduceTime>2021-06-29T14:50:15.011643661+08:00</ProduceTime>
<ContentType>image/jpeg</ContentType>
<MediaType>image</MediaType>
<LatLong>30.134390,120.074997</LatLong>
<Title>test</Title>
<OSSExpiration>2024-12-01T12:00:00.000Z</OSSExpiration>
<AccessControlAllowOrigin>https://aliyundoc.com</AccessControlAllowOrigin>
<AccessControlRequestMethod>PUT</AccessControlRequestMethod>
<ServerSideDataEncryption>SM4</ServerSideDataEncryption>
<ServerSideEncryptionKeyId>9468da86-3509-4f8d-a61e-6eab1eac****</ServerSideEncryptionKeyId>
<CacheControl>no-cache</CacheControl>
<ContentDisposition>attachment; filename =test.jpg</ContentDisposition>
<ContentEncoding>UTF-8</ContentEncoding>
<ContentLanguage>zh-CN</ContentLanguage>
// The following content may be returned if MediaType is set to image:
<ImageHeight>500</ImageHeight>
<ImageWidth>270</ImageWidth>
// The following content may be returned if MediaType is set to video:
<VideoWidth>1080</VideoWidth>
<VideoHeight>1920</VideoHeight>
<VideoStreams>
<VideoStream>
<CodecName>h264</CodecName>
<Language>en</Language>
<Bitrate>5407765</Bitrate>
<FrameRate>25/1</FrameRate>
<StartTime>0</StartTime>
<Duration>22.88</Duration>
<FrameCount>572</FrameCount>
<BitDepth>8</BitDepth>
<PixelFormat>yuv420p</PixelFormat>
<ColorSpace>bt709</ColorSpace>
<Height>720</Height>
<Width>1280</Width>
</VideoStream>
<VideoStream>
<CodecName>h264</CodecName>
<Language>en</Language>
<Bitrate>5407765</Bitrate>
<FrameRate>25/1</FrameRate>
<StartTime>0</StartTime>
<Duration>22.88</Duration>
<FrameCount>572</FrameCount>
<BitDepth>8</BitDepth>
<PixelFormat>yuv420p</PixelFormat>
<ColorSpace>bt709</ColorSpace>
<Height>720</Height>
<Width>1280</Width>
</VideoStream>
</VideoStreams>
// The following content may be returned if MediaType is set to audio/video:
<AudioStreams>
<AudioStream>
<CodecName>aac</CodecName>
<Bitrate>1048576</Bitrate>
<SampleRate>48000</SampleRate>
<StartTime>0.0235</StartTime>
<Duration>3.690667</Duration>
<Channels>2</Channels>
<Language>en</Language>
</AudioStream>
</AudioStreams>
// The following content may be returned if MediaType is set to video:
<Subtitles>
<Subtitle>
<CodecName>mov_text</CodecName>
<Language>en</Language>
<StartTime>0</StartTime>
<Duration>71.378</Duration>
</Subtitle>
<Subtitle>
<CodecName>mov_text</CodecName>
<Language>en</Language>
<StartTime>72</StartTime>
<Duration>71.378</Duration>
</Subtitle>
</Subtitles>
<Bitrate>5407765</Bitrate>
<Artist>Jane</Artist>
<AlbumArtist>Jenny</AlbumArtist>
<Composer>Jane</Composer>
<Performer>Jane</Performer>
<Album>FirstAlbum</Album>
<Duration>71.378</Duration>
<Addresses>
<Address>
<AddressLine>No. 969, Wenyi West Road, Yuhang District, Hangzhou City, Zhejiang Province, China</AddressLine>
<City>Hangzhou</City>
<Country>China</Country>
<District>Yuhang</District>
<Language>zh-Hans</Language>
<Province>Zhejiang</Province>
<Township>Wenyi West Road</Township>
</Address>
<Address>
<AddressLine>No. 970, Wenyi West Road, Yuhang District, Hangzhou City, Zhejiang Province, China</AddressLine>
<City>Hangzhou</City>
<Country>China</Country>
<District>Yuhang</District>
<Language>zh-Hans2</Language>
<Province>Zhejiang</Province>
<Township>Wenyi West Road</Township>
</Address>
</Addresses>
<OSSObjectType>Normal</OSSObjectType>
<OSSStorageClass>Standard</OSSStorageClass>
<OSSTaggingCount>2</OSSTaggingCount>
<OSSTagging>
<Tagging>
<Key>key</Key>
<Value>val</Value>
</Tagging>
<Tagging>
<Key>key2</Key>
<Value>val2</Value>
</Tagging>
</OSSTagging>
<OSSUserMeta>
<UserMeta>
<Key>key</Key>
<Value>val</Value>
</UserMeta>
</OSSUserMeta>
</File>
</Files>
</MetaQuery>
Query examples
Queries can be nested. You can use nested queries to perform complex queries and exact match. The following sample code provides examples on how to perform nested queries.
If you want to query an object whose name is exampleobject.txt and whose size is less than 1,000 bytes, you can configure the query as shown in the following example:
{ "SubQueries":[ { "Field":"Filename", "Value": "exampleobject.txt", "Operation":"eq" }, { "Field":"Size", "Value":"1000", "Operation":"lt" } ], "Operation":"and" }
If you want to query objects that are prefixed with
exampledir/
, contain thetype=document
orowner=John
tag, and are larger than 10 MB in size, you can configure the query as shown in the following example:{ "SubQueries": [ { "Field": "Filename", "Value": "exampledir/", "Operation": "prefix" }, { "Field": "Size", "Value": "1048576", "Operation": "gt" }, { "SubQueries": [ { "Field": "OSSTagging.type", "Value": "document", "Operation": "eq" }, { "Field": "OSSTagging.owner", "Value": "John", "Operation": "eq" } ], "Operation": "or" } ], "Operation": "and" }
You can also perform aggregate operations to collect and analyze different data based on the specified conditions. For example, you can calculate the sum, count, average value, or maximum value of all files that meet the query conditions. You can also calculate the size distribution of images that meet the query conditions.