Call the OpenMetaQuery operation to enable metadata management for a bucket and select a retrieval mode. OSS creates a metadata index library, builds indexes for all objects in the bucket, and performs near-real-time incremental scans for new objects.
Notes
-
By default, an Alibaba Cloud account has permission to enable metadata management. To use a RAM user, grant the
oss:OpenMetaQuerypermission. Grant custom permissions to a RAM user.
Request syntax
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>
<WorkflowParameters>
<WorkflowParameter>
<Name>VideoInsightEnable</Name>
<Value>True</Value> // Specifies whether to enable video content awareness.
</WorkflowParameter>
<WorkflowParameter>
<Name>ImageInsightEnable</Name>
<Value>True</Value> // Specifies whether to enable image content awareness.
</WorkflowParameter>
</WorkflowParameters>
<Filters>
<Filter>Size > 1024, FileModifiedTime > 2025-06-03T09:20:47.999Z</Filter> // Configures file filter conditions.
<Filter>Filename prefix (YWEvYmIv)</Filter>
</Filters>
</MetaQuery>Request headers
This operation uses only Common request headers.
Request elements
|
Name |
Type |
Required |
Example |
Description |
|
mode |
String |
Yes |
basic |
The retrieval mode. Valid values:
|
|
role |
String |
No |
my-oss-role |
The RAM role name for accessing OSS. You can grant permissions to the role in the console to ensure secure access. |
|
MetaQuery |
Container |
No |
N/A |
The container for metadata query. Child node: Filters |
|
WorkflowParameters |
Container |
No |
N/A |
The container for workflow parameters. Configures AI content awareness features. |
|
WorkflowParameter |
Container |
No |
N/A |
The container for a single workflow parameter. Parent node: WorkflowParameters |
|
Name |
String |
No |
VideoInsightEnable |
The name of the workflow parameter.
|
|
Value |
String |
No |
True |
The value of the workflow parameter.
|
|
Filters |
Container |
No |
N/A |
The container for filter conditions. Supports both AND and OR logical operations with comparison operators. Maximum: five OR operations and four AND operations.
Example: filter files larger than 1024 bytes modified after 2025-06-03T09:20:47.999Z, or files with prefix `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. Supported fields and operators are listed in Appendix: Variables and operators supported by the Filters field. The example value filters for files 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-request-id: 5C06A3B67B8B5A3DA422299D
x-oss-server-time: 544
SDK
Supported SDKs:
ossutil
The corresponding ossutil command is open-meta-query.
Appendix: Variables and operators supported by the Filters field
|
Name |
Type |
Supported operators |
Description |
Filter example |
|
Size |
Integer |
|
Filters by file size. |
|
|
Filename |
String |
|
Filters by filename. The filename must be URL-safe Base64 encoded. |
|
|
FileModifiedTime |
String |
|
Filters by file modification time. Use the RFC3339Nano time format. |
|
|
OSSTagging.* |
String |
|
Filters by tag. The tag key and value must be URL-safe Base64 encoded. |
|