OpenMetaQuery
Call the OpenMetaQuery operation to enable the Data Management feature for a bucket and select a retrieval mode. After the feature is enabled, OSS creates a metadata index library for the bucket and builds indexes for all objects in it. OSS then performs Near Real-Time incremental scans to index new objects.
Notes
-
By default, an Alibaba Cloud account has the permission to enable the Data Management feature. If you want to use a Resource Access Management (RAM) user to enable the feature, you must ensure that the RAM user is granted the
oss:OpenMetaQuerypermission. For more information, see Grant custom access policies to a RAM user. -
For more information about data indexes, see Data indexes.
Request syntax
POST /?metaQuery&comp=add&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>
<Filters>
<Filter>filter1</Filter>
<Filter>filter2</Filter>
</Filters>
</MetaQuery>
Request headers
|
Name |
Type |
Required |
Example |
Description |
|
mode |
String |
Yes |
|
The retrieval mode. Valid values:
|
Request elements
|
Name |
Type |
Required |
Example |
Description |
|
MetaQuery |
Container |
No |
None |
The container for the metadata query. Child node: Filters |
|
Filters |
Container |
No |
None |
The container for filter conditions. It supports logical operations such as AND and OR, and comparison operators.
The following example filters for objects that are larger than 1024 bytes and were modified after 2025-06-03T09:20:47.999Z, or objects whose prefixes are `aa/bb/`. `YWEvYmIv` is the URL-safe Base64 encoding of `aa/bb/`.
Child node: Filter Parent node: MetaQuery |
|
Filter |
String |
No |
|
The filter condition expression. For information about the supported fields and comparison operators, see Appendix: Supported variables and operators for the Filters field. The example value filters for objects that are larger than 1024 bytes and were modified after 2025-06-03T09:20:47.999Z. Parent node: Filters |
Response headers
The response contains only common response headers. For more information, see Common response headers.
Examples
Request example
POST /?metaQuery&comp=add&mode=basic HTTP/1.1
Host: oss-example.oss-cn-hangzhou.aliyuncs.com
Date: Thu, 17 Apr 2025 13:08:38 GMT
Authorization: OSS4-HMAC-SHA256 Credential=LTAI********************/20250417/cn-hangzhou/oss/aliyun_v4_request,Signature=a7c3554c729d71929e0b84489addee6b2e8d5cb48595adfc51868c299c0c218e
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<MetaQuery>
<Filters>
<Filter>Size > 1024, FileModifiedTime > 2025-06-03T09:20:47.999Z</Filter>
<Filter>Filename prefix (YWEvYmIv)</Filter>
</Filters>
</MetaQuery>
Response example
HTTP/1.1 200 OK
x-oss-request-id: 5C1B138A109F4E405B2D****
Date: Mon, 26 Jul 2021 13:08:38 GMT
Content-Length: 0
Connection: keep-alive
Server: AliyunOSS
x-oss-server-time: 544
SDK
The following software development kits (SDKs) are available for this operation:
ossutil command-line tool
For the ossutil command for the OpenMetaQuery operation, see open-meta-query.
Appendix: Supported variables and operators for the Filters field
|
Name |
Type |
Supported operators |
Description |
Filter example |
|
Size |
Integer |
|
Filters by object size. |
|
|
Filename |
String |
|
Filters by object name. The object name must be URL-safe Base64-encoded. |
|
|
FileModifiedTime |
String |
|
Filters by object modification time. Use the RFC 3339 time format. |
|
|
OSSTagging.* |
String |
|
Filters by tag. The tag key and value must be URL-safe Base64-encoded. |
|