You can use the DoMetaQuery operation to retrieve data from the default dataset of a bucket for which metadata management is enabled. This operation supports two modes. The basic mode filters, sorts, and aggregates data based on structured properties such as Size, Filename, FileModifiedTime, and OSSTagging. The semantic mode performs vector similarity searches based on natural language text and lets you add structured filter conditions. Parameters related to search by image are reserved and are not currently supported.
Notes
The RAM user that calls this operation must have the
oss:MetaQuerypermission.Before you call this operation, you must enable metadata management by calling OpenMetaQuery.
The
modemust match themodethat was set when you called OpenMetaQuery. A bucket enabled inbasicmode can be queried only using scalar search. A bucket enabled insemanticmode can be queried using eitherbasicorsemanticsearch.The
semanticmode does not support paging or aggregation. The response does not containNextToken, and the<Aggregations>element in the request has no effect.The
basicmode does not support the<Filters>element. The<Filters>element is used for filtering during indexing, which is configured when you call OpenMetaQuery.This operation queries only the default dataset. The system creates and uses the default dataset only if
RouteRuleis not specified when you call OpenMetaQuery. If you configureRouteRulewhen you enable metadata management, files are routed to the corresponding datasets based on the routing rules. To query these datasets, use SimpleQuery or SemanticQuery and explicitly specify thedatasetName.
Request syntax
Scalar search
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>Vector search
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>An aerial view of a snow-covered forest</Query>
<MediaTypes>
<MediaType>image</MediaType>
</MediaTypes>
<SimpleQuery>{"Operation":"gt", "Field": "Size", "Value": "30"}</SimpleQuery>
</MetaQuery>Request headers
DescribeRegions uses only common request headers. For more information, see Common request headers.
Request elements
Scalar search
Name | Type | Required | Example | Description |
mode | String | Yes | basic | Specifies that the search mode is scalar search. |
MetaQuery | Container | Yes | N/A | The container for query conditions. Child nodes: NextToken, MaxResults, Query, Sort, Order, and Aggregations |
NextToken | String | No | MTIzNDU2Nzg6aW1tdGVzdDpleGFtcGxlYnVja2V0OmRhdGFzZXQwMDE6b3NzOi8vZXhhbXBsZWJ1Y2tldC9zYW1wbGVvYmplY3QxLmpw**** | The token used for pagination when the total number of objects is greater than the value of MaxResults. The list of object information is returned in lexicographical order, starting from the object that corresponds to NextToken. When you call this operation for the first time, leave this parameter empty. Parent node: MetaQuery |
MaxResults | Integer | No | 5 | The maximum number of objects to return. Valid values: 0 to 100. If you do not set this parameter or set it to 0, the default value of 100 is used. Parent node: MetaQuery |
Query | String | Yes | {"Field": "Size","Value": "1048576","Operation": "gt"} | The query condition. It includes the following options:
For more information about Query examples, see DoMetaQuery. Parent node: MetaQuery |
Sort | String | No | Size | Sorts the results by the specified field. For a list of fields that support sorting, see Appendix: Fields and operators for scalar search. Parent node: MetaQuery |
Order | String | No | asc | The sorting order. Valid values:
Parent node: MetaQuery |
Aggregations | Container | No | N/A | The container for aggregation operation information. Child node: Aggregation Parent node: MetaQuery |
Aggregation | Container | No | N/A | The container for a single aggregation operation. Child nodes: Field and Operation Parent node: Aggregations |
Field | String | No | Size | The field name. For information about the supported fields and the operators supported by each field, see Appendix: Fields and operators for scalar search. Parent node: Aggregation |
Operation | String | No | sum | The operator for the aggregation operation. Valid values:
Parent node: Aggregation |
Vector search
Name | Type | Required | Example | Description |
mode | String | Yes | semantic | Specifies that the search mode is vector search. |
MetaQuery | Container | Yes | N/A | The container for 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 you do not set this parameter or set it to 0, the default value of 100 is used. Parent node: MetaQuery |
Query | String | Yes | An aerial view of a snow-covered forest | The content to search for. Parent node: MetaQuery |
MediaTypes | Container | Yes | N/A | The conditions for searching multimedia metadata. Parent node: MetaQuery Child node: MediaType |
MediaType | String | Yes | image | The type of multimedia to search. Valid values:
Parent node: MediaTypes |
SimpleQuery | String | No | {"Operation":"gt", "Field": "Size", "Value": "30"} | The query condition. It includes the following options:
Parent node: MetaQuery |
Response headers
This operation uses only common response headers. For more information, see Common response headers.
Response elements
Scalar search
Name | Type | Example | Description |
MetaQuery | Container | N/A | The container for the query results. Child nodes: NextToken, Files, and Aggregations |
NextToken | String | MTIzNDU2Nzg6aW1tdGVzdDpleGFtcGxlYnVja2V0OmRhdGFzZXQwMDE6b3NzOi8vZXhhbXBsZWJ1Y2tldC9zYW1wbGVvYmplY3QxLmpw**** | The token used for pagination when the total number of objects is greater than the value of MaxResults. To return the remaining results, use this value for NextToken in the next request. This parameter has a value only when not all objects are returned. Parent node: MetaQuery |
Files | Container | N/A | The container for object information. Child node: File Parent node: MetaQuery |
File | Container | N/A | The container for the information of a single object. Child nodes: Filename, Size, FileModifiedTime, OSSObjectType, OSSStorageClass, ObjectACL, ETag, OSSTaggingCount, OSSTagging, and OSSCRC64 Parent node: Files |
Filename | String | exampleobject.txt | The full path of the object. Parent node: File |
Size | Integer | 120 | The size of the object. Unit: bytes. Parent node: File |
FileModifiedTime | String | 2025-05-19T16:14:38+08:00 | The last modified time of the object. The time is in the RFC 3339 nano format. Parent node: File |
FileCreateTime | String | 2021-07-29T15:04:05+07:00 | The creation time of the object. The time is in the RFC 3339 nano format. Parent node: File |
OSSObjectType | String | Normal | The type of the object. Valid values:
Parent node: File |
OSSStorageClass | String | Standard | The storage class of the object. Valid values:
Parent node: File |
ObjectACL | String | default | The access permissions of the object. Valid values:
Parent node: File |
ETag | String | "fba9dede5f27731c9771645a3986****" | When an object is created, a corresponding ETag is generated. The ETag is used to identify the content of an object.
Note You can use the ETag to check whether the object content has changed. We do not recommend using the ETag as the MD5 hash of the object content to verify data integrity. Parent node: File |
OSSTaggingCount | Integer | 2 | The number of tags of the object. Parent node: File |
OSSTagging | Container | N/A | The container for tag information. Child node: Tagging Parent node: File |
Tagging | Container | N/A | The container for a single tag. Child nodes: Key and Value Parent node: OSSTagging |
Key | String | owner | The key of the tag or user-defined metadata. User-defined metadata must be prefixed with Parent nodes: Tagging and UserMeta |
Value | String | John | The value of the tag or user-defined metadata. Parent nodes: Tagging and UserMeta |
OSSCRC64 | String | 4858A48BD1466884 | The 64-bit CRC value of the object. This value is calculated based on the CRC-64/XZ standard. Parent node: File |
Aggregations | Container | N/A | The container for aggregation operation information. Child nodes: Field, Operation, Operation, Value, and Groups Parent node: MetaQuery |
Field | String | Size | The field name. Parent node: Aggregations |
Operation | String | sum | The aggregation operator. Parent node: Aggregations |
Value | Floating-point number | 200 | The result of the aggregation operation. Parent node: Aggregations |
Groups | Container | N/A | The list of results from grouping and aggregation. Child nodes: Value and Count Parent node: Aggregations |
Value | String | 100 | The value of the grouping and aggregation. Parent node: Groups |
Count | Integer | 5 | The total count for the grouping and aggregation. Parent node: Groups |
Vector search
Name | Type | Example | Description |
MetaQuery | Container | N/A | The container for the query results. Child node: Files |
Files | Container | N/A | The list of object information. Child node: File Parent node: MetaQuery |
File | Container | N/A | The information of a single object. Parent node: Files Child nodes: URI, Filename, Size, ObjectACL, FileModifiedTime, ETag, OSSCRC64, CreationTime, ContentType, MediaType, LatLong, Title, OSSExpiration, AccessControlAllowOrigin, AccessControlRequestMethod, CacheControl, ContentDisposition, ContentEncoding, ContentLanguage, ImageHeight, ImageWidth, VideoWidth, VideoHeight, VideoStreams, AudioStreams, Subtitles, Bitrate, Artist, AlbumArtist, Composer, Performer, Album, Duration, Addresses, OSSObjectType, OSSStorageClass, OSSTaggingCount, OSSTagging |
URI | String | oss://examplebucket/test-object.jpg | The full path of the object. Parent node: File |
Filename | String | exampleobject.txt | The name of the object. Parent node: File |
Size | Integer | 120 | The size of the object. Unit: bytes. Parent node: File |
ObjectACL | String | default | The access permissions of the object. Valid values:
Parent node: File |
FileModifiedTime | String | 2025-05-19T16:15:33+08:00 | The last modified time of the object. The time is in the RFC 3339 nano format. Parent node: File |
ETag | String | "fba9dede5f27731c9771645a3986****" | When an object is created, a corresponding ETag is generated. The ETag is used to identify the content of an object.
Note You can use the ETag to check whether the object content has changed. We do not recommend using the ETag as the MD5 hash of the object content to verify data integrity. Parent node: File |
OSSCRC64 | String | 4858A48BD1466884 | The 64-bit CRC value of the object. This value is calculated based on the CRC-64/XZ standard. Parent node: File |
ProduceTime | String | 2021-06-29T14:50:13.011643661+08:00 | The time when the photo or video was captured by the device. Parent node: File |
ContentType | String | image/jpeg | The MIME type. Parent node: File |
MediaType | String | image | The multimedia type. Parent node: File |
LatLong | String | 30.134390,120.074997 | The latitude and longitude information. Parent node: File |
Title | String | test | The file title. Parent node: File |
OSSExpiration | String | 2124-12-01T12:00:00.000Z | The expiration time of the file. Parent node: File |
AccessControlAllowOrigin | String | The allowed origin for cross-origin requests. Parent node: File | |
AccessControlRequestMethod | String | PUT | The method used in the cross-origin request. Parent node: File |
CacheControl | String | no-cache | The web page caching behavior when the object is downloaded. Parent node: File |
ContentDisposition | String | attachment; filename =test.jpg | The name of the object when it is downloaded. Parent node: File |
ContentEncoding | String | UTF-8 | The encoding format of the object content when it is downloaded. Parent node: File |
ContentLanguage | String | zh-CN | The language used in the object content. Parent node: File |
ImageHeight | Integer | 500 | The height of the image. Unit: pixels (px). Parent node: File |
ImageWidth | Integer | 270 | The width of the image. Unit: pixels (px). Parent node: File |
VideoWidth | Integer | 1080 | The width of the video frame. Unit: pixels (px). Parent node: File |
VideoHeight | Integer | 1920 | The height of the video frame. Unit: pixels (px). Parent node: File |
VideoStreams | Container | N/A | The list of video streams. Parent node: File Child node: VideoStream |
VideoStream | Container | N/A | The video stream. Parent node: VideoStreams Child nodes: CodecName, Language, Bitrate, FrameRate, StartTime, Duration, FrameCount, BitDepth, PixelFormat, ColorSpace, Height, and Width |
CodecName | String | h264 | The name of the encoder. Parent node: VideoStream |
Language | String | en | The language used in the video stream. The format is BCP 47. Parent node: VideoStream |
Bitrate | Integer | 5407765 | The bitrate. Unit: bits per second (bit/s). Parent node: VideoStream |
FrameRate | String | 25/1 | The frame rate of the video stream. Parent node: VideoStream |
StartTime | Double-precision floating-point number | 0.000000 | The start time of the video stream. Unit: seconds (s). Parent node: VideoStream |
Duration | Double-precision floating-point number | 22.88 | The duration of the video stream. Unit: seconds (s). Parent node: VideoStream |
FrameCount | Integer | 572 | The number of video frames. Parent node: VideoStream |
BitDepth | Integer | 8 | The bit depth of the pixel. Parent node: VideoStream |
PixelFormat | String | yuv420p | The pixel format of the video stream. Parent node: VideoStream |
ColorSpace | String | bt709 | The color space. Parent node: VideoStream |
Height | Integer | 720 | The height of the video stream frame. Unit: pixels (px). Parent node: VideoStream |
Width | Integer | 1280 | The width of the video stream frame. Unit: pixels (px). Parent node: VideoStream |
AudioStreams | Container | N/A | The list of audio streams. Parent node: File Child node: AudioStream |
AudioStream | Container | N/A | The audio stream. Parent node: AudioStreams Child nodes: CodecName, Bitrate, SampleRate, StartTime, Duration, Channels, and Language |
CodecName | String | aac | The name of the encoder. Parent node: AudioStream |
Bitrate | Integer | 320087 | The bitrate. Unit: bits per second (bit/s). Parent node: AudioStream |
SampleRate | Integer | 48000 | The sample rate. Unit: hertz (Hz). Parent node: AudioStream |
StartTime | Double-precision floating-point number | 0.0235 | The start time of the audio stream. Unit: seconds (s). Parent node: AudioStream |
Duration | Double-precision floating-point number | 3.690667 | The duration of the audio stream. Unit: seconds (s). Parent node: AudioStream |
Channels | Integer | 2 | The number of sound channels. Parent node: AudioStream |
Language | String | en | The language used in the audio stream. The format is BCP 47. Parent node: AudioStream |
Subtitles | Container | N/A | The list of caption streams. Parent node: File Child node: Subtitle |
Subtitle | Container | N/A | The caption stream. Parent node: Subtitles Child nodes: CodecName, Language, StartTime, and Duration |
CodecName | String | mov_text | The name of the encoder. Parent node: Subtitle |
Language | String | en | The language of the caption. The format is BCP 47. Parent node: Subtitle |
StartTime | Double-precision floating-point number | 0.000000 | The start time of the caption stream. Unit: seconds (s). Parent node: Subtitle |
Duration | Double-precision floating-point number | 71.378 | The duration of the caption stream. Unit: seconds (s). Parent node: Subtitle |
Bitrate | Integer | 13091201 | The bitrate. Unit: bits per second (bit/s). Parent node: File |
Artist | String | Jane | The artist. Parent node: File |
AlbumArtist | String | Jenny | Artist. Parent node: File |
Composer | String | Jane | The composer. Parent node: File |
Performer | String | Jane | The performer. Parent node: File |
Album | String | FirstAlbum | The album. Parent node: File |
Duration | Double-precision floating-point number | 15.263000 | The total duration of the video. Unit: seconds. Parent node: File |
Addresses | Container | N/A | The address information. Parent node: File Child node: Address |
Address | Container | N/A | The address information. Parent node: Addresses Child nodes: AddressLine, City, District, Language, Province, and Township |
AddressLine | String | No. 969, Wenyi West Road, Yuhang District, Hangzhou City, Zhejiang Province, China | The full address. Parent node: Address |
City | String | Hangzhou | The city. Parent node: Address |
District | String | Yuhang District | The district. Parent node: Address |
Language | String | zh-Hans | The language. The format is BCP 47. Parent node: Address |
Province | String | Zhejiang Province | The province. Parent node: Address |
Township | String | Wenyi West Road | The street. Parent node: Address |
OSSObjectType | String | Normal | The type of the object. Parent node: File |
OSSStorageClass | String | Standard | The storage class of the object. Parent node: File |
OSSTaggingCount | Integer | 2 | The number of tags of the object. Parent node: File |
OSSTagging | Container | N/A | The list of tag information. Child node: Tagging Parent node: File |
Tagging | Container | N/A | The container for a single tag. Child nodes: Key and Value Parent node: OSSTagging |
Key | String | owner | The key of the tag. Parent node: Tagging |
Value | String | John | The value of the tag. Parent node: Tagging |
Key | String | owner | The key of the user-defined metadata. Parent node: Tagging |
Value | String | John | The value of the user-defined metadata. Parent node: Tagging |
Insights | Container | N/A | The description of the file. Child nodes: Video and Image |
Video | Container | N/A | The description of the video file. Parent node: Insights Child nodes: Caption and Description |
Caption | String | N/A | A brief description. Parent node: Video |
Image | Container | N/A | The description of the image file. Parent node: Insights Child nodes: Caption and Description |
Caption | String | N/A | A brief description. Parent node: Image |
Description | String | N/A | A detailed description. Parent node: Image |
Examples
Request examples
Scalar search: Return the first 10 files that are larger than 1 MB in descending order of size.
POST /?metaQuery&action=doMetaQuery&mode=basic HTTP/1.1 Host: examplebucket.oss-cn-hangzhou.aliyuncs.com Date: Wed, 20 May 2026 09:00:00 GMT Authorization: OSS4-HMAC-SHA256 Credential=LTAI********************/20260520/cn-hangzhou/oss/aliyun_v4_request,Signature=a7c3554c729d71929e0b84489addee6b2e8d5cb48595adfc51868c299c0c218e Content-Type: application/xml <?xml version="1.0" encoding="UTF-8"?> <MetaQuery> <Query>{"Field":"Size","Operation":"gt","Value":"1048576"}</Query> <Sort>Size</Sort> <Order>desc</Order> <MaxResults>10</MaxResults> </MetaQuery>Scalar search: Group files by ContentType and calculate the total size in bytes.
POST /?metaQuery&action=doMetaQuery&mode=basic HTTP/1.1 Host: examplebucket.oss-cn-hangzhou.aliyuncs.com Date: Wed, 20 May 2026 09:00:00 GMT Authorization: OSS4-HMAC-SHA256 Credential=LTAI********************/20260520/cn-hangzhou/oss/aliyun_v4_request,Signature=a7c3554c729d71929e0b84489addee6b2e8d5cb48595adfc51868c299c0c218e Content-Type: application/xml <?xml version="1.0" encoding="UTF-8"?> <MetaQuery> <Query>{"Field":"Size","Operation":"gt","Value":"0"}</Query> <MaxResults>0</MaxResults> <Aggregations> <Aggregation> <Field>Size</Field> <Operation>sum</Operation> </Aggregation> <Aggregation> <Field>ContentType</Field> <Operation>group</Operation> </Aggregation> </Aggregations> </MetaQuery>Vector search: Perform a semantic search for images using the text "a cat in the living room".
POST /?metaQuery&action=doMetaQuery&mode=semantic HTTP/1.1 Host: examplebucket.oss-cn-hangzhou.aliyuncs.com Date: Wed, 20 May 2026 09:00:00 GMT Authorization: OSS4-HMAC-SHA256 Credential=LTAI********************/20260520/cn-hangzhou/oss/aliyun_v4_request,Signature=a7c3554c729d71929e0b84489addee6b2e8d5cb48595adfc51868c299c0c218e Content-Type: application/xml <?xml version="1.0" encoding="UTF-8"?> <MetaQuery> <Query>A cat in the living room</Query> <MediaTypes> <MediaType>image</MediaType> </MediaTypes> <SimpleQuery>{"Field":"Size","Operation":"gt","Value":"102400"}</SimpleQuery> <MaxResults>20</MaxResults> </MetaQuery>
Response examples
Scalar search:
HTTP/1.1 200 OK x-oss-request-id: 64C8B6F4E7C5A3A8B9D6E7F6 Date: Wed, 20 May 2026 09:00:01 GMT Content-Type: application/xml Server: AliyunOSS <?xml version="1.0" encoding="UTF-8"?> <MetaQuery> <NextToken>MTIzNDU2</NextToken> <TotalHits>123</TotalHits> <Files> <File> <Filename>photos/sunset.jpg</Filename> <Size>2097152</Size> <FileModifiedTime>2026-05-19T15:30:00.000+08:00</FileModifiedTime> <ContentType>image/jpeg</ContentType> <ObjectACL>default</ObjectACL> <OSSStorageClass>Standard</OSSStorageClass> <ETag>"D41D8CD98F00B204E9800998ECF8427E"</ETag> <OSSTagging> <Tagging> <Key>routing-dataset</Key> <Value>photos-2026</Value> </Tagging> </OSSTagging> </File> </Files> <Aggregations> <Aggregation> <Field>Size</Field> <Operation>sum</Operation> <Value>12345678</Value> </Aggregation> <Aggregation> <Field>ContentType</Field> <Operation>group</Operation> <Groups> <Group> <Value>image/jpeg</Value> <Count>256</Count> </Group> <Group> <Value>video/mp4</Value> <Count>48</Count> </Group> </Groups> </Aggregation> </Aggregations> </MetaQuery>Vector search:
HTTP/1.1 200 OK x-oss-request-id: 64C8B6F4E7C5A3A8B9D6E7F7 Date: Wed, 20 May 2026 09:00:01 GMT Content-Type: application/xml Server: AliyunOSS <?xml version="1.0" encoding="UTF-8"?> <MetaQuery> <Files> <File> <Filename>photos/cat-in-living-room.jpg</Filename> <Size>1572864</Size> <FileModifiedTime>2026-05-18T10:00:00.000+08:00</FileModifiedTime> <ContentType>image/jpeg</ContentType> <MediaType>image</MediaType> <ImageWidth>4032</ImageWidth> <ImageHeight>3024</ImageHeight> <Insights> <Image> <Caption>An orange cat is lying on the sofa in the living room, with sunlight streaming in from the window.</Caption> </Image> </Insights> <Labels> <Label> <LabelName>Cat</LabelName> <LabelConfidence>0.98</LabelConfidence> </Label> <Label> <LabelName>Living room</LabelName> <LabelConfidence>0.92</LabelConfidence> </Label> </Labels> </File> </Files> </MetaQuery>