alibabacloud-oss-manage-metaquery
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseOSS Vector Search & AI Content Awareness
OSS 向量搜索与AI内容感知
Leverage multimodal AI models to extract semantic descriptions and concise summaries from images, videos, audio, and documents stored in OSS Buckets. Build searchable vector indexes to enable advanced retrieval capabilities such as text-to-image and text-to-video search.
利用多模态AI模型,提取存储在OSS Bucket中的图片、视频、音频和文档的语义描述和简明摘要。构建可搜索的向量索引,以实现以文搜图、以文搜视频等高级检索能力。
Prerequisites
前置要求
- Aliyun CLI (>= 3.3.1)
Pre-check: Aliyun CLI >= 3.3.1 required This skill uses Aliyun CLI for all OSS operations except opening MetaQuery. If Aliyun CLI is already installed, ossutil does not need to be installed separately. Run the following command to verify the version:If not installed or the version is below 3.3.1, refer to references/cli-installation-guide.md for installation instructions, then run:aliyun version
aliyun configure set --auto-plugin-install trueThis configuration enables automatic plugin installation.
- Update the aliyun ossutil plugin
Troubleshooting:unknown flag error If you encounter--user-agentwhen running a command, the ossutil plugin version is too old. Run the following command to update to the latest version:Error: unknown flag: --user-agentbashaliyun ossutil updateAfter the update, re-run the original command.
bash
undefined- Aliyun CLI (>= 3.3.1)
预检查:需安装 Aliyun CLI >= 3.3.1 版本 除开启MetaQuery之外的所有OSS操作,本技能均使用Aliyun CLI完成。如果已安装Aliyun CLI,则无需单独安装ossutil。 运行以下命令验证版本:若未安装或版本低于3.3.1,请参考 references/cli-installation-guide.md 完成安装,随后运行:aliyun version
aliyun configure set --auto-plugin-install true该配置将启用插件自动安装功能。
- 更新 aliyun ossutil 插件
故障排查:未知参数错误 若运行命令时遇到--user-agent错误,说明ossutil插件版本过旧,运行以下命令更新至最新版本:Error: unknown flag: --user-agentbashaliyun ossutil update更新完成后重新运行原命令即可。
bash
undefinedPython SDK dependencies
Python SDK 依赖
pip install oss2==2.19.1 alibabacloud-credentials==1.0.8
> Notes:
> - Required: Aliyun CLI, Python dependencies oss2 and alibabacloud-credentials
> - Not required: ossutil
> - The only operation that requires Python: opening MetaQuery (AI Content Awareness + semantic search)
> **Security Rules:**
> - **NEVER** read, echo, or print AK/SK values (e.g., `echo $ALIBABA_CLOUD_ACCESS_KEY_ID` is FORBIDDEN)
> - **NEVER** ask the user to input AK/SK directly in the conversation or command linepip install oss2==2.19.1 alibabacloud-credentials==1.0.8
> 注意事项:
> - 必备依赖:Aliyun CLI、Python 依赖库 oss2 和 alibabacloud-credentials
> - 非必备依赖:ossutil
> - 唯一需要Python的操作:开启MetaQuery(AI内容感知 + 语义搜索)
> **安全规则:**
> - **绝对不要** 读取、回显或打印AK/SK的值(例如禁止执行 `echo $ALIBABA_CLOUD_ACCESS_KEY_ID`)
> - **绝对不要** 要求用户在对话或命令行中直接输入AK/SKArchitecture
架构
User Request -> OSS Bucket -> AI Content Awareness Engine -> Semantic Feature Extraction -> Vector Index -> Semantic Search
|
Images/Videos/Audio/Docs -> Detailed Description (~100 chars) + Concise Summary (<=20 chars)Core Components:
OSS Bucket + Data Index + Vector Search + AI Content Awareness用户请求 -> OSS Bucket -> AI内容感知引擎 -> 语义特征提取 -> 向量索引 -> 语义搜索
|
图片/视频/音频/文档 -> 详细描述(~100字) + 简明摘要(<=20字)核心组件:
OSS Bucket + 数据索引 + 向量搜索 + AI内容感知Usage Restrictions
使用限制
Supported Regions
支持的区域
| Region Category | Region List |
|---|---|
| East China | cn-hangzhou, cn-shanghai |
| North China | cn-qingdao, cn-beijing, cn-zhangjiakou |
| South China | cn-shenzhen, cn-guangzhou |
| Southwest China | cn-chengdu |
| Other | cn-hongkong, ap-southeast-1 (Singapore), us-east-1 (Virginia) |
Note: If the user's Bucket is in a region not listed above, vector-mode MetaQuery and content awareness cannot be enabled, and an EC Codeerror will be returned. Guide the user to create a new Bucket in a supported region.0037-00000001
| 区域类别 | 区域列表 |
|---|---|
| 华东 | cn-hangzhou, cn-shanghai |
| 华北 | cn-qingdao, cn-beijing, cn-zhangjiakou |
| 华南 | cn-shenzhen, cn-guangzhou |
| 西南 | cn-chengdu |
| 其他 | cn-hongkong, ap-southeast-1 (新加坡), us-east-1 (弗吉尼亚) |
注意: 如果用户的Bucket位于上述未列出的区域,则无法开启向量模式的MetaQuery和内容感知,会返回错误码。请引导用户在支持的区域创建新的Bucket。0037-00000001
File Types
支持的文件类型
- Supported: Images, videos, audio, documents
- Multipart uploads: Only objects that have been assembled via are shown
CompleteMultipartUpload
- 支持: 图片、视频、音频、文档
- 分片上传: 仅展示通过 完成组装的对象
CompleteMultipartUpload
Performance Reference
性能参考
OSS Internal Bandwidth and QPS
OSS 内网带宽与QPS
| Region | Internal Bandwidth | Default QPS |
|---|---|---|
| cn-beijing, cn-hangzhou, cn-shanghai, cn-shenzhen | 10Gbps | 1250 |
| Other regions | 1Gbps | 1250 |
This bandwidth and QPS is provided exclusively for vector search and does not consume the Bucket's QoS quota.
| 区域 | 内网带宽 | 默认QPS |
|---|---|---|
| cn-beijing, cn-hangzhou, cn-shanghai, cn-shenzhen | 10Gbps | 1250 |
| 其他区域 | 1Gbps | 1250 |
该带宽和QPS为向量搜索专属,不会占用Bucket的QoS配额。
Existing File Index Build Time
存量文件索引构建时间
| File Type | 10 Million Files | 100 Million Files | 1 Billion Files |
|---|---|---|---|
| Structured data & images | 2-3 hours | 1 day | ~10 days |
| Videos, documents, audio | 2-3 days | 7-9 days | - |
| 文件类型 | 1000万文件 | 1亿文件 | 10亿文件 |
|---|---|---|---|
| 结构化数据 & 图片 | 2-3小时 | 1天 | ~10天 |
| 视频、文档、音频 | 2-3天 | 7-9天 | - |
Incremental Updates and Search Latency
增量更新与搜索延迟
- Incremental updates: When QPS < 1250, latency is typically minutes to hours
- Search response: Sub-second, default timeout 30 seconds
- 增量更新: 当QPS < 1250时,延迟通常为几分钟到几小时
- 搜索响应: 亚秒级,默认超时时间30秒
Dangerous Operation Confirmation
危险操作确认
Before executing any of the following dangerous operations, you MUST confirm with the user first and obtain explicit consent before proceeding:
- Delete Bucket: -- Deletes the entire Bucket, irreversible
aliyun ossutil rm oss://<bucket-name> -b --user-agent AlibabaCloud-Agent-Skills - Delete Object: -- Deletes a specific file
aliyun ossutil rm oss://<bucket-name>/<object-key> --user-agent AlibabaCloud-Agent-Skills - Batch Delete Objects: -- Recursively deletes all files in the Bucket
aliyun ossutil rm oss://<bucket-name>/ --recursive --user-agent AlibabaCloud-Agent-Skills - Close MetaQuery: -- Closes the metadata index; all indexed data will be cleared
aliyun ossutil api close-meta-query --bucket <bucket-name> --user-agent AlibabaCloud-Agent-Skills - Open MetaQuery: -- Opens the metadata index; existing data will start being indexed. If the bucket has more than 1000 objects, confirm with the user first.
python scripts/open_metaquery.py --region <your-region> --bucket <your-bucket-name> --endpoint <your-endpoint> - Create Bucket: -- Creates a Bucket
aliyun ossutil api put-bucket --bucket <bucket> --region <region-id> --user-agent AlibabaCloud-Agent-Skills
When confirming, explain the following to the user:
- The specific operation to be performed
- The scope of impact (which files/resources will be deleted or closed)
- Whether the operation is reversible (most delete operations are irreversible)
执行以下任意危险操作前,你必须先与用户确认,获得明确同意后才可继续:
- 删除Bucket: -- 删除整个Bucket,操作不可逆
aliyun ossutil rm oss://<bucket-name> -b --user-agent AlibabaCloud-Agent-Skills - 删除对象: -- 删除指定文件
aliyun ossutil rm oss://<bucket-name>/<object-key> --user-agent AlibabaCloud-Agent-Skills - 批量删除对象: -- 递归删除Bucket内所有文件
aliyun ossutil rm oss://<bucket-name>/ --recursive --user-agent AlibabaCloud-Agent-Skills - 关闭MetaQuery: -- 关闭元数据索引,所有已索引数据将被清空
aliyun ossutil api close-meta-query --bucket <bucket-name> --user-agent AlibabaCloud-Agent-Skills - 开启MetaQuery: -- 开启元数据索引,存量数据将开始索引。如果Bucket内对象超过1000个,需先与用户确认
python scripts/open_metaquery.py --region <your-region> --bucket <your-bucket-name> --endpoint <your-endpoint> - 创建Bucket: -- 创建Bucket
aliyun ossutil api put-bucket --bucket <bucket> --region <region-id> --user-agent AlibabaCloud-Agent-Skills
确认时需向用户说明以下内容:
- 即将执行的具体操作
- 影响范围(哪些文件/资源会被删除或关闭)
- 操作是否可逆(绝大多数删除操作不可逆)
RAM Permissions
RAM权限
See references/ram-policies.md
请参考 references/ram-policies.md
Critical Rules (Must Follow)
关键规则(必须遵守)
Rule 1: Opening MetaQuery MUST use the Python script
规则1:开启MetaQuery必须使用Python脚本
PROHIBITED:
bash
aliyun ossutil api open-meta-query oss://my-bucket --mode semanticREQUIRED:
bash
python scripts/open_metaquery.py --region cn-hangzhou --bucket my-bucketReason: Only the Python script or SDK can correctly configure to enable AI Content Awareness (ImageInsightEnable and VideoInsightEnable). Without this, semantic search quality will be severely degraded.
WorkflowParameters禁止操作:
bash
aliyun ossutil api open-meta-query oss://my-bucket --mode semantic要求操作:
bash
python scripts/open_metaquery.py --region cn-hangzhou --bucket my-bucket原因: 只有Python脚本或SDK可以正确配置 以启用AI内容感知(ImageInsightEnable和VideoInsightEnable)。缺少该配置会导致语义搜索质量严重下降。
WorkflowParametersRule 2: Must ask the user when Bucket name conflicts
规则2:Bucket名称冲突时必须询问用户
When creating a Bucket and encountering a error:
BucketAlreadyExists- Immediately stop all subsequent operations
- Inform the user: "The Bucket name is already taken"
- Ask the user to choose:
- Option 1: Use the existing bucket (requires explicit user confirmation)
- Option 2: Choose a new bucket name (user provides the new name)
- Wait for the user's response before continuing PROHIBITED:
- Automatically modifying the bucket name (e.g., appending ,
-2, etc.)-new - Using an existing bucket without asking the user
创建Bucket时遇到 错误时:
BucketAlreadyExists- 立即停止 所有后续操作
- 告知用户:"该Bucket名称已被占用"
- 询问用户 选择:
- 选项1:使用现有Bucket(需用户明确确认)
- 选项2:选择新的Bucket名称(由用户提供新名称)
- 等待用户响应 后再继续操作 禁止操作:
- 自动修改Bucket名称(例如追加 、
-2等后缀)-new - 未询问用户的情况下直接使用现有Bucket
Rule 3: Use Aliyun CLI by default for all operations except opening MetaQuery
规则3:除开启MetaQuery外,所有操作默认使用Aliyun CLI
The following operations should use Aliyun CLI by default:
- Create Bucket
- Query Bucket info
- Query Bucket statistics
- Upload files
- Query MetaQuery status
- Execute semantic search
- Close MetaQuery
- Delete Object / Bucket
Goal: Use the command uniformly, minimizing dependency on ossutil.
aliyun
以下操作默认应使用Aliyun CLI:
- 创建Bucket
- 查询Bucket信息
- 查询Bucket统计数据
- 上传文件
- 查询MetaQuery状态
- 执行语义搜索
- 关闭MetaQuery
- 删除对象 / Bucket
目标:统一使用 命令,最小化对ossutil的依赖。
aliyun
Rule 4: If Aliyun CLI is installed, ossutil is not needed
规则4:如果已安装Aliyun CLI,则无需ossutil
This skill does not require ossutil to be installed by default.
As long as Aliyun CLI >= 3.3.1 is installed and the following has been executed:
bash
aliyun configure set --auto-plugin-install trueIt can be used as the default execution tool.
本技能默认不需要安装ossutil。只要安装了Aliyun CLI >= 3.3.1且执行过以下命令:
bash
aliyun configure set --auto-plugin-install true就可以将其作为默认执行工具。
Core Workflows
核心工作流
Task 1: Create Bucket and Upload Files
任务1:创建Bucket并上传文件
Always confirm with the user before creating a bucket. Proceed only after the user agrees.
bash
undefined创建Bucket前必须与用户确认,用户同意后才可继续。
bash
undefined1.1 Create Bucket
1.1 创建Bucket
aliyun ossutil api put-bucket --bucket examplebucket --region <region-id> --user-agent AlibabaCloud-Agent-Skills
aliyun ossutil api put-bucket --bucket examplebucket --region <region-id> --user-agent AlibabaCloud-Agent-Skills
1.2 Download files
1.2 下载文件
aliyun ossutil cp oss://example-bucket/test_medias/ /tmp/test_medias_download/ -r --region cn-hangzhou --user-agent AlibabaCloud-Agent-Skills
aliyun ossutil cp oss://example-bucket/test_medias/ /tmp/test_medias_download/ -r --region cn-hangzhou --user-agent AlibabaCloud-Agent-Skills
1.3 Upload files
1.3 上传文件
aliyun ossutil cp /tmp/test_medias_download/ oss://example-bucket/test_medias/ -r --region cn-hangzhou --user-agent AlibabaCloud-Agent-Skills
undefinedaliyun ossutil cp /tmp/test_medias_download/ oss://example-bucket/test_medias/ -r --region cn-hangzhou --user-agent AlibabaCloud-Agent-Skills
undefinedTask 2: Enable Vector Search & AI Content Awareness (Python script or SDK only)
任务2:启用向量搜索与AI内容感知(仅支持Python脚本或SDK)
WARNING: You MUST useto open MetaQuery. Usingpython scripts/open_metaquery.pyis STRICTLY PROHIBITED (it cannot configure WorkflowParameters, which prevents enabling AI Content Awareness features ImageInsightEnable and VideoInsightEnable, severely degrading semantic search quality).aliyun ossutil api open-meta-query
警告:你必须使用开启MetaQuery,严格禁止使用python scripts/open_metaquery.py(该方式无法配置WorkflowParameters,导致无法启用AI内容感知功能ImageInsightEnable和VideoInsightEnable,严重降低语义搜索质量)。aliyun ossutil api open-meta-query
Using the Python Script (Mandatory)
使用Python脚本(强制要求)
Before executing the Python script, complete the following environment setup:
1. Install Python dependencies:
bash
pip install oss2==2.19.1 alibabacloud-credentials==1.0.82. Configure credentials:
The Python script uses the default credential chain to automatically discover credentials (supporting environment variables, , ECS instance roles, etc.). No explicit AK/SK handling is needed in the code. Ensure credentials are configured via the command.
alibabacloud-credentials~/.aliyun/config.jsonaliyun configure3. Verify RAM permissions:
Users must have the minimum RAM permissions required for MetaQuery. See references/ram-policies.md.
If the user encounters an error, check that RAM permissions are correctly configured.
AccessDeniedEnablement Process:
-
Prepare the Bucket: a. If the user requests creating a new Bucket:
- Run with the user-specified bucket name
aliyun ossutil api put-bucket --bucket examplebucket --user-agent AlibabaCloud-Agent-Skills - If creation fails with a error:
BucketAlreadyExists- Immediately stop the operation
- Inform the user: "The Bucket name is already taken (it may have been created by you or another user)"
<bucket-name> - You MUST ask the user: "Would you like to: 1) Use this existing bucket? or 2) Choose a new bucket name?"
- Wait for the user's explicit response before continuing. Do not modify the bucket name or use the existing bucket without permission. b. If the user provides an existing bucket:
- First verify the bucket exists using
aliyun ossutil api get-bucket-info --bucket <bucket-name> --user-agent AlibabaCloud-Agent-Skills - If it does not exist, ask the user whether to create it
- Run
-
Verify Bucket object count: After the user provides a bucket, check the object count. If it exceeds 1000, warn the user that enabling MetaQuery will incur costs. Use the following command to get the bucket's object count:bash
aliyun ossutil api get-bucket-stat --bucket <your-bucket-name> --output-format json --user-agent AlibabaCloud-Agent-SkillsThefield in the response indicates the number of objects.ObjectCount- If the object count exceeds 1000, warn the user that enabling MetaQuery will incur costs and confirm whether to proceed.
- If the object count is 0, ask the user which files to upload. Upload command:
bash
aliyun ossutil api put-object --bucket <your-bucket-name> --key <object-key> --body file://<local-file-path> --user-agent AlibabaCloud-Agent-Skills
-
Run the Python script: After the above steps are complete, attempt to open MetaQuery using the Python script. Python script example:
bash
python scripts/open_metaquery.py --region <your-region> --bucket <your-bucket-name> --endpoint <your-endpoint>执行Python脚本前,需完成以下环境配置:
1. 安装Python依赖:
bash
pip install oss2==2.19.1 alibabacloud-credentials==1.0.82. 配置凭证:
Python脚本使用 默认凭证链自动发现凭证(支持环境变量、、ECS实例角色等),代码中无需显式处理AK/SK。请确保已通过 命令配置好凭证。
alibabacloud-credentials~/.aliyun/config.jsonaliyun configure3. 验证RAM权限:
用户必须拥有MetaQuery所需的最低RAM权限,参考 references/ram-policies.md。如果用户遇到 错误,请检查RAM权限配置是否正确。
AccessDenied启用流程:
-
准备Bucket: a. 如果用户要求创建新Bucket:
- 使用用户指定的Bucket名称执行
aliyun ossutil api put-bucket --bucket examplebucket --user-agent AlibabaCloud-Agent-Skills - 如果创建失败并返回 错误:
BucketAlreadyExists- 立即停止操作
- 告知用户:"Bucket名称 已被占用(可能是你本人或其他用户创建的)"
<bucket-name> - 必须询问用户:"你希望:1) 使用这个现有Bucket?还是2) 选择新的Bucket名称?"
- 等待用户明确回复后再继续,不得私自修改Bucket名称或使用现有Bucket。 b. 如果用户提供现有Bucket:
- 首先使用 验证Bucket是否存在
aliyun ossutil api get-bucket-info --bucket <bucket-name> --user-agent AlibabaCloud-Agent-Skills - 如果不存在,询问用户是否需要创建
- 使用用户指定的Bucket名称执行
-
验证Bucket对象数量:用户提供Bucket后,检查对象数量。如果超过1000,需告知用户启用MetaQuery会产生费用,确认是否继续。 使用以下命令获取Bucket的对象数量:bash
aliyun ossutil api get-bucket-stat --bucket <your-bucket-name> --output-format json --user-agent AlibabaCloud-Agent-Skills响应中的字段代表对象数量。ObjectCount- 如果对象数量超过1000,告知用户启用MetaQuery会产生费用,确认是否继续
- 如果对象数量为0,询问用户需要上传哪些文件,上传命令:
bash
aliyun ossutil api put-object --bucket <your-bucket-name> --key <object-key> --body file://<local-file-path> --user-agent AlibabaCloud-Agent-Skills
-
运行Python脚本:完成上述步骤后,使用Python脚本尝试开启MetaQuery。 Python脚本示例:
bash
python scripts/open_metaquery.py --region <your-region> --bucket <your-bucket-name> --endpoint <your-endpoint>Troubleshooting MetaQuery Enablement Issues
MetaQuery启用问题排查
Use the command to check MetaQuery status:
get-meta-query-statusbash
aliyun ossutil api get-meta-query-status --bucket <your-bucket-name> --output-format json --user-agent AlibabaCloud-Agent-SkillsBased on the returned status:
- Status is : MetaQuery is being closed. The user should retry later.
Deleted - Status is or
Running: MetaQuery has already been created. Check the following two conditions:Ready- Whether is
MetaQueryModesemantic - Whether contains the following configuration:
WorkflowParametersxml<WorkflowParameters> <WorkflowParameter><Name>ImageInsightEnable</Name><Value>True</Value></WorkflowParameter> <WorkflowParameter><Name>VideoInsightEnable</Name><Value>True</Value></WorkflowParameter> </WorkflowParameters>
and bothMetaQueryMode=semanticandVideoInsightEnableareImageInsightEnable, the user has successfully enabled MetaQuery in vector mode with content awareness (which greatly improves semantic search quality). No further action is needed. If these conditions are not met, recommend the user switch to a different bucket and start over.True - Whether
使用 命令检查MetaQuery状态:
get-meta-query-statusbash
aliyun ossutil api get-meta-query-status --bucket <your-bucket-name> --output-format json --user-agent AlibabaCloud-Agent-Skills根据返回的状态处理:
- 状态为 :MetaQuery正在关闭中,请用户稍后重试
Deleted - 状态为 或
Running:MetaQuery已创建,检查以下两个条件:Ready- 是否为
MetaQueryModesemantic - 是否包含以下配置:
WorkflowParametersxml<WorkflowParameters> <WorkflowParameter><Name>ImageInsightEnable</Name><Value>True</Value></WorkflowParameter> <WorkflowParameter><Name>VideoInsightEnable</Name><Value>True</Value></WorkflowParameter> </WorkflowParameters>
且MetaQueryMode=semantic和VideoInsightEnable均为ImageInsightEnable,说明用户已成功开启带内容感知的向量模式MetaQuery(可大幅提升语义搜索质量),无需进一步操作。如果不满足上述条件,建议用户切换到其他Bucket重新操作。True
Task 3: Execute Semantic Search
任务3:执行语义搜索
Prerequisites for MetaQuery Search
MetaQuery搜索前置要求
Before using MetaQuery for search, confirm the following:
- Verify MetaQuery is enabled:
bash
aliyun ossutil api get-meta-query-status --bucket <your-bucket-name> --output-format json --user-agent AlibabaCloud-Agent-Skills - If MetaQuery is not enabled: Complete the enablement process first. Refer to Task 2 to enable it using the Python script.
- Check index scan status: The field from
Phaseindicates the current scan phase:get-meta-query-status- : Full scan in progress. Search is not available yet. Wait for the full scan to complete.
FullScanning - : Incremental scan in progress. The index has been largely built and search can be performed normally.
IncrementalScanning
- Verify MetaQuery state is : MetaQuery is only available when
RunningisState. If the state isRunningor any non-Readystate, you may need to wait or re-enable it.Running
1. Prepare the meta-query.xml file:
Create a file to define query conditions. For detailed format, field descriptions, and complete examples, see references/metaquery.md.
Example of semantic vector search for video files containing "person" (MediaTypes can only be one of: video, image, audio, document):
meta-query.xmlxml
<MetaQuery>
<MediaTypes><MediaType>video</MediaType></MediaTypes>
<Query>person</Query>
</MetaQuery>Example of scalar search where file size > 30B and file modification time > 2025-06-03T09:20:47.999Z:
xml
<MetaQuery>
<Query>{"SubQueries":[{"Field":"Size","Value":"30","Operation":"gt"},{"Field":"FileModifiedTime","Value":"2025-06-03T09:20:47.999Z","Operation":"gt"}],"Operation":"and"}</Query>
</MetaQuery>2. Execute the search command:
This example uses semantic vector search. The file defines the query conditions, and search results return the most similar files.
meta-query.xmlbash
aliyun ossutil api do-meta-query --bucket <bucket-name> --meta-query file://meta-query.xml --meta-query-mode semantic --user-agent AlibabaCloud-Agent-SkillsFor scalar search, use
--meta-query-mode basicFor detailed command parameters, see the DoMetaQuery section in references/related-apis.md.
3. Optimizing search result display:
After search completes, when displaying results to the user, use the parameter to generate preview images or cover frames for image and video files, making it easier for the user to visually review search results. If the user's current channel supports multimedia files, send them directly to the user.
x-oss-processVideo files -- Get video cover snapshot:
bash
aliyun ossutil presign oss://<bucket-name>/<video-object-key> --query-param x-oss-process=video/snapshot,t_0,f_png,w_0,h_0 --user-agent AlibabaCloud-Agent-SkillsParameters: : Capture frame at 0ms as cover; : Output format PNG; : Width/height 0 means original resolution.
t_0f_pngw_0,h_0Image files -- Get image preview link:
bash
aliyun ossutil presign oss://<bucket-name>/<image-object-key> --user-agent AlibabaCloud-Agent-SkillsNote: Thecommand generates a signed temporary access URL that can be opened directly in a browser for preview during its validity period. For image files, you can also add image processing parameters viaaliyun ossutil presign(e.g., resize, crop):x-oss-processbashaliyun ossutil presign oss://<bucket-name>/<image-object-key> --query-param x-oss-process=image/resize,w_200 --user-agent AlibabaCloud-Agent-SkillsThis generates a thumbnail preview to reduce loading time.
使用MetaQuery进行搜索前,需确认以下内容:
- 验证MetaQuery已启用:
bash
aliyun ossutil api get-meta-query-status --bucket <your-bucket-name> --output-format json --user-agent AlibabaCloud-Agent-Skills
2. **如果MetaQuery未启用**:先完成启用流程,参考任务2使用Python脚本启用。
3. **检查索引扫描状态**:`get-meta-query-status` 返回的 `Phase` 字段代表当前扫描阶段:
- `FullScanning`:全量扫描进行中,**暂不支持搜索**,请等待全量扫描完成
- `IncrementalScanning`:增量扫描进行中,索引已基本构建完成,可以正常执行搜索
4. **验证MetaQuery状态为 `Running`**:只有当 `State` 为 `Running` 时MetaQuery才可用。如果状态为 `Ready` 或其他非`Running`状态,可能需要等待或重新启用。
**1. 准备meta-query.xml文件:**
创建 `meta-query.xml` 文件定义查询条件,详细格式、字段说明和完整示例参考 [references/metaquery.md](references/metaquery.md)。
搜索包含"person"的视频文件的语义向量搜索示例(MediaTypes仅可取值为:video、image、audio、document):
```xml
<MetaQuery>
<MediaTypes><MediaType>video</MediaType></MediaTypes>
<Query>person</Query>
</MetaQuery>查询文件大小 > 30B且文件修改时间 > 2025-06-03T09:20:47.999Z的标量搜索示例:
xml
<MetaQuery>
<Query>{"SubQueries":[{"Field":"Size","Value":"30","Operation":"gt"},{"Field":"FileModifiedTime","Value":"2025-06-03T09:20:47.999Z","Operation":"gt"}],"Operation":"and"}</Query>
</MetaQuery>2. 执行搜索命令:
本示例为语义向量搜索, 文件定义查询条件,搜索结果返回最匹配的文件。
meta-query.xmlbash
aliyun ossutil api do-meta-query --bucket <bucket-name> --meta-query file://meta-query.xml --meta-query-mode semantic --user-agent AlibabaCloud-Agent-Skills标量搜索请使用
--meta-query-mode basic详细命令参数参考 references/related-apis.md 中的DoMetaQuery部分。
3. 优化搜索结果展示:
搜索完成后,向用户展示结果时,可使用 参数为图片和视频文件生成预览图或封面帧,方便用户直观查看搜索结果。如果用户当前渠道支持多媒体文件,可直接发送给用户。
x-oss-process视频文件 -- 获取视频封面快照:
bash
aliyun ossutil presign oss://<bucket-name>/<video-object-key> --query-param x-oss-process=video/snapshot,t_0,f_png,w_0,h_0 --user-agent AlibabaCloud-Agent-Skills参数说明::取0毫秒处的帧作为封面;:输出格式为PNG;:宽高为0代表使用原始分辨率。
t_0f_pngw_0,h_0图片文件 -- 获取图片预览链接:
bash
aliyun ossutil presign oss://<bucket-name>/<image-object-key> --user-agent AlibabaCloud-Agent-Skills注意:命令生成的是签名临时访问URL,有效期内可直接在浏览器打开预览。对于图片文件,还可以通过aliyun ossutil presign添加图片处理参数(例如缩放、裁剪):x-oss-processbashaliyun ossutil presign oss://<bucket-name>/<image-object-key> --query-param x-oss-process=image/resize,w_200 --user-agent AlibabaCloud-Agent-Skills该命令会生成缩略图预览,减少加载时间。
Troubleshooting MetaQuery Search Issues
MetaQuery搜索问题排查
User asks "Why wasn't a specific file found?"
用户询问"为什么找不到特定文件?"
When a user reports that a specific uploaded file is missing from search results, troubleshoot based on the MetaQuery configuration:
a. Content awareness is NOT enabled:
If the user's MetaQuery does not have content awareness enabled (i.e., or is not in ), possible reasons include:
VideoInsightEnableImageInsightEnableTrueWorkflowParameters- The file's metadata index has not been fully built yet. Wait for the index scan to complete (check the field via
Phase).aliyun ossutil api get-meta-query-status --bucket <bucket-name> --output-format json --user-agent AlibabaCloud-Agent-Skills - Without content awareness, search is based only on basic file metadata (filename, size, type, etc.) and cannot perform semantic understanding of file contents, resulting in limited search effectiveness.
- Recommendation: Suggest the user enable content awareness to improve search quality. Since existing MetaQuery configurations cannot be directly modified, recommend the user switch to a new bucket and re-enable MetaQuery with content awareness following the Task 2 process.
b. Content awareness IS enabled:
If the user's MetaQuery has content awareness enabled but a specific file still cannot be found, possible reasons include:
- File is still being processed: Content awareness requires deep analysis of files (e.g., image recognition, video understanding), which takes longer, especially for video files. Check the field via
Phase:aliyun ossutil api get-meta-query-status --bucket <bucket-name> --output-format json --user-agent AlibabaCloud-Agent-Skills- : The overall index is still in full scan mode. Wait patiently.
FullScanning - : Newly uploaded files are being processed incrementally. Usually wait a few minutes.
IncrementalScanning
- Unsupported file format: Some file formats may not be supported by content awareness. In this case, search can only use basic metadata.
- Search keywords don't match: The user's search keywords may not semantically match the file content. Suggest the user try adjusting their search keywords to use descriptions closer to the actual file content.
当用户反馈上传的特定文件未出现在搜索结果中时,根据MetaQuery配置排查:
a. 未启用内容感知:
如果用户的MetaQuery未启用内容感知(即 中的 或 不为 ),可能的原因包括:
WorkflowParametersVideoInsightEnableImageInsightEnableTrue- 文件的元数据索引尚未构建完成,请等待索引扫描完成(通过 查看
aliyun ossutil api get-meta-query-status --bucket <bucket-name> --output-format json --user-agent AlibabaCloud-Agent-Skills字段)。Phase - 未启用内容感知时,搜索仅基于基础文件元数据(文件名、大小、类型等),无法对文件内容进行语义理解,搜索效果有限。
- 建议:建议用户开启内容感知提升搜索质量。由于现有MetaQuery配置无法直接修改,建议用户切换到新的Bucket,按照任务2的流程重新开启带内容感知的MetaQuery。
b. 已启用内容感知:
如果用户的MetaQuery已启用内容感知但仍找不到特定文件,可能的原因包括:
- 文件仍在处理中:内容感知需要对文件进行深度分析(例如图像识别、视频理解),耗时更长,尤其是视频文件。通过 查看
aliyun ossutil api get-meta-query-status --bucket <bucket-name> --output-format json --user-agent AlibabaCloud-Agent-Skills字段:Phase- :整体索引仍处于全量扫描模式,请耐心等待
FullScanning - :新上传的文件正在增量处理,通常等待几分钟即可
IncrementalScanning
- 不支持的文件格式:部分文件格式可能不被内容感知支持,此时仅能使用基础元数据搜索
- 搜索关键词不匹配:用户的搜索关键词可能与文件内容语义不匹配,建议用户调整搜索关键词,使用更贴近文件实际内容的描述
Task 4: Query Data Index Status (aliyun ossutil)
任务4:查询数据索引状态(aliyun ossutil)
bash
aliyun ossutil api get-meta-query-status --bucket <bucket-name> --output-format json --user-agent AlibabaCloud-Agent-SkillsFor detailed descriptions of returned fields (State, Phase, MetaQueryMode, etc.), see the GetMetaQueryStatus section in references/related-apis.md.
bash
aliyun ossutil api get-meta-query-status --bucket <bucket-name> --output-format json --user-agent AlibabaCloud-Agent-Skills返回字段(State、Phase、MetaQueryMode等)的详细说明参考 references/related-apis.md 中的GetMetaQueryStatus部分。
Verification
验证
See references/verification-method.md
参考 references/verification-method.md
Resource Cleanup
资源清理
bash
undefinedbash
undefinedClose the data index. (Dangerous operation -- confirm with the user first)
关闭数据索引(危险操作 -- 需先与用户确认)
aliyun ossutil api close-meta-query --bucket <bucket-name> --user-agent AlibabaCloud-Agent-Skills
> **Warning**: After closing the data index, all indexed data will be cleared. (Dangerous operation -- confirm with the user first)aliyun ossutil api close-meta-query --bucket <bucket-name> --user-agent AlibabaCloud-Agent-Skills
> **警告**:关闭数据索引后,所有已索引数据将被清空(危险操作 -- 需先与用户确认)Alternative Python Scripts for OSS Operations
OSS操作的替代Python脚本
When aliyun ossutil is unavailable, you can use Python scripts as alternatives. See the Python SDK Scripts section in references/related-apis.md.
当无法使用aliyun ossutil时,可使用Python脚本作为替代,参考 references/related-apis.md 中的Python SDK脚本部分。