alibabacloud-oss-manage-metaquery

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

OSS 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

前置要求

  1. 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:
aliyun 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 configure set --auto-plugin-install true
This configuration enables automatic plugin installation.
  1. Update the aliyun ossutil plugin
Troubleshooting:
--user-agent
unknown flag error
If you encounter
Error: unknown flag: --user-agent
when running a command, the ossutil plugin version is too old. Run the following command to update to the latest version:
bash
aliyun ossutil update
After the update, re-run the original command.
bash
undefined
  1. Aliyun CLI (>= 3.3.1)
预检查:需安装 Aliyun CLI >= 3.3.1 版本 除开启MetaQuery之外的所有OSS操作,本技能均使用Aliyun CLI完成。如果已安装Aliyun CLI,则无需单独安装ossutil。 运行以下命令验证版本:
aliyun version
若未安装或版本低于3.3.1,请参考 references/cli-installation-guide.md 完成安装,随后运行:
aliyun configure set --auto-plugin-install true
该配置将启用插件自动安装功能。
  1. 更新 aliyun ossutil 插件
故障排查:
--user-agent
未知参数错误
若运行命令时遇到
Error: unknown flag: --user-agent
错误,说明ossutil插件版本过旧,运行以下命令更新至最新版本:
bash
aliyun ossutil update
更新完成后重新运行原命令即可。
bash
undefined

Python 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 line
pip 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/SK

Architecture

架构

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 CategoryRegion List
East Chinacn-hangzhou, cn-shanghai
North Chinacn-qingdao, cn-beijing, cn-zhangjiakou
South Chinacn-shenzhen, cn-guangzhou
Southwest Chinacn-chengdu
Othercn-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 Code
0037-00000001
error will be returned. Guide the user to create a new Bucket in a supported region.
区域类别区域列表
华东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和内容感知,会返回错误码
0037-00000001
。请引导用户在支持的区域创建新的Bucket。

File Types

支持的文件类型

  • Supported: Images, videos, audio, documents
  • Multipart uploads: Only objects that have been assembled via
    CompleteMultipartUpload
    are shown

  • 支持: 图片、视频、音频、文档
  • 分片上传: 仅展示通过
    CompleteMultipartUpload
    完成组装的对象

Performance Reference

性能参考

OSS Internal Bandwidth and QPS

OSS 内网带宽与QPS

RegionInternal BandwidthDefault QPS
cn-beijing, cn-hangzhou, cn-shanghai, cn-shenzhen10Gbps1250
Other regions1Gbps1250
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-shenzhen10Gbps1250
其他区域1Gbps1250
该带宽和QPS为向量搜索专属,不会占用Bucket的QoS配额。

Existing File Index Build Time

存量文件索引构建时间

File Type10 Million Files100 Million Files1 Billion Files
Structured data & images2-3 hours1 day~10 days
Videos, documents, audio2-3 days7-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:
    aliyun ossutil rm oss://<bucket-name> -b --user-agent AlibabaCloud-Agent-Skills
    -- Deletes the entire Bucket, irreversible
  • Delete Object:
    aliyun ossutil rm oss://<bucket-name>/<object-key> --user-agent AlibabaCloud-Agent-Skills
    -- Deletes a specific file
  • Batch Delete Objects:
    aliyun ossutil rm oss://<bucket-name>/ --recursive --user-agent AlibabaCloud-Agent-Skills
    -- Recursively deletes all files in the Bucket
  • Close MetaQuery:
    aliyun ossutil api close-meta-query --bucket <bucket-name> --user-agent AlibabaCloud-Agent-Skills
    -- Closes the metadata index; all indexed data will be cleared
  • Open MetaQuery:
    python scripts/open_metaquery.py --region <your-region> --bucket <your-bucket-name> --endpoint <your-endpoint>
    -- Opens the metadata index; existing data will start being indexed. If the bucket has more than 1000 objects, confirm with the user first.
  • Create Bucket:
    aliyun ossutil api put-bucket --bucket <bucket> --region <region-id> --user-agent AlibabaCloud-Agent-Skills
    -- Creates a Bucket
When confirming, explain the following to the user:
  1. The specific operation to be performed
  2. The scope of impact (which files/resources will be deleted or closed)
  3. Whether the operation is reversible (most delete operations are irreversible)
执行以下任意危险操作前,你必须先与用户确认,获得明确同意后才可继续:
  • 删除Bucket:
    aliyun ossutil rm oss://<bucket-name> -b --user-agent AlibabaCloud-Agent-Skills
    -- 删除整个Bucket,操作不可逆
  • 删除对象:
    aliyun ossutil rm oss://<bucket-name>/<object-key> --user-agent AlibabaCloud-Agent-Skills
    -- 删除指定文件
  • 批量删除对象:
    aliyun ossutil rm oss://<bucket-name>/ --recursive --user-agent AlibabaCloud-Agent-Skills
    -- 递归删除Bucket内所有文件
  • 关闭MetaQuery:
    aliyun ossutil api close-meta-query --bucket <bucket-name> --user-agent AlibabaCloud-Agent-Skills
    -- 关闭元数据索引,所有已索引数据将被清空
  • 开启MetaQuery:
    python scripts/open_metaquery.py --region <your-region> --bucket <your-bucket-name> --endpoint <your-endpoint>
    -- 开启元数据索引,存量数据将开始索引。如果Bucket内对象超过1000个,需先与用户确认
  • 创建Bucket:
    aliyun ossutil api put-bucket --bucket <bucket> --region <region-id> --user-agent AlibabaCloud-Agent-Skills
    -- 创建Bucket
确认时需向用户说明以下内容:
  1. 即将执行的具体操作
  2. 影响范围(哪些文件/资源会被删除或关闭)
  3. 操作是否可逆(绝大多数删除操作不可逆)

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 semantic
REQUIRED:
bash
python scripts/open_metaquery.py --region cn-hangzhou --bucket my-bucket
Reason: Only the Python script or SDK can correctly configure
WorkflowParameters
to enable AI Content Awareness (ImageInsightEnable and VideoInsightEnable). Without this, semantic search quality will be severely degraded.
禁止操作:
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可以正确配置
WorkflowParameters
以启用AI内容感知(ImageInsightEnable和VideoInsightEnable)。缺少该配置会导致语义搜索质量严重下降。

Rule 2: Must ask the user when Bucket name conflicts

规则2:Bucket名称冲突时必须询问用户

When creating a Bucket and encountering a
BucketAlreadyExists
error:
  1. Immediately stop all subsequent operations
  2. Inform the user: "The Bucket name is already taken"
  3. 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)
  4. Wait for the user's response before continuing PROHIBITED:
  • Automatically modifying the bucket name (e.g., appending
    -2
    ,
    -new
    , etc.)
  • Using an existing bucket without asking the user
创建Bucket时遇到
BucketAlreadyExists
错误时:
  1. 立即停止 所有后续操作
  2. 告知用户:"该Bucket名称已被占用"
  3. 询问用户 选择:
    • 选项1:使用现有Bucket(需用户明确确认)
    • 选项2:选择新的Bucket名称(由用户提供新名称)
  4. 等待用户响应 后再继续操作 禁止操作:
  • 自动修改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
    aliyun
    command uniformly, minimizing dependency on ossutil.
以下操作默认应使用Aliyun CLI:
  • 创建Bucket
  • 查询Bucket信息
  • 查询Bucket统计数据
  • 上传文件
  • 查询MetaQuery状态
  • 执行语义搜索
  • 关闭MetaQuery
  • 删除对象 / Bucket 目标:统一使用
    aliyun
    命令,最小化对ossutil的依赖。

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 true
It 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
undefined

1.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
undefined
aliyun ossutil cp /tmp/test_medias_download/ oss://example-bucket/test_medias/ -r --region cn-hangzhou --user-agent AlibabaCloud-Agent-Skills
undefined

Task 2: Enable Vector Search & AI Content Awareness (Python script or SDK only)

任务2:启用向量搜索与AI内容感知(仅支持Python脚本或SDK)

WARNING: You MUST use
python scripts/open_metaquery.py
to open MetaQuery. Using
aliyun ossutil api open-meta-query
is STRICTLY PROHIBITED (it cannot configure WorkflowParameters, which prevents enabling AI Content Awareness features ImageInsightEnable and VideoInsightEnable, severely degrading semantic search quality).
警告:你必须使用
python scripts/open_metaquery.py
开启MetaQuery,严格禁止使用
aliyun ossutil api open-meta-query
(该方式无法配置WorkflowParameters,导致无法启用AI内容感知功能ImageInsightEnable和VideoInsightEnable,严重降低语义搜索质量)。

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.8
2. Configure credentials: The Python script uses the
alibabacloud-credentials
default credential chain to automatically discover credentials (supporting environment variables,
~/.aliyun/config.json
, ECS instance roles, etc.). No explicit AK/SK handling is needed in the code. Ensure credentials are configured via the
aliyun configure
command.
3. Verify RAM permissions: Users must have the minimum RAM permissions required for MetaQuery. See references/ram-policies.md. If the user encounters an
AccessDenied
error, check that RAM permissions are correctly configured.
Enablement Process:
  1. Prepare the Bucket: a. If the user requests creating a new Bucket:
    • Run
      aliyun ossutil api put-bucket --bucket examplebucket --user-agent AlibabaCloud-Agent-Skills
      with the user-specified bucket name
    • If creation fails with a
      BucketAlreadyExists
      error:
      • Immediately stop the operation
      • Inform the user: "The Bucket name
        <bucket-name>
        is already taken (it may have been created by you or another user)"
      • 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
  2. 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-Skills
    The
    ObjectCount
    field in the response indicates the number of objects.
    • 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
  3. 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.8
2. 配置凭证: Python脚本使用
alibabacloud-credentials
默认凭证链自动发现凭证(支持环境变量、
~/.aliyun/config.json
、ECS实例角色等),代码中无需显式处理AK/SK。请确保已通过
aliyun configure
命令配置好凭证。
3. 验证RAM权限: 用户必须拥有MetaQuery所需的最低RAM权限,参考 references/ram-policies.md。如果用户遇到
AccessDenied
错误,请检查RAM权限配置是否正确。
启用流程:
  1. 准备Bucketa. 如果用户要求创建新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:
    • 首先使用
      aliyun ossutil api get-bucket-info --bucket <bucket-name> --user-agent AlibabaCloud-Agent-Skills
      验证Bucket是否存在
    • 如果不存在,询问用户是否需要创建
  2. 验证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
  3. 运行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
get-meta-query-status
command to check MetaQuery status:
bash
aliyun ossutil api get-meta-query-status --bucket <your-bucket-name> --output-format json --user-agent AlibabaCloud-Agent-Skills
Based on the returned status:
  • Status is
    Deleted
    : MetaQuery is being closed. The user should retry later.
  • Status is
    Running
    or
    Ready
    : MetaQuery has already been created. Check the following two conditions:
    • Whether
      MetaQueryMode
      is
      semantic
    • Whether
      WorkflowParameters
      contains the following configuration:
      xml
      <WorkflowParameters>
        <WorkflowParameter><Name>ImageInsightEnable</Name><Value>True</Value></WorkflowParameter>
        <WorkflowParameter><Name>VideoInsightEnable</Name><Value>True</Value></WorkflowParameter>
      </WorkflowParameters>
    If
    MetaQueryMode=semantic
    and both
    VideoInsightEnable
    and
    ImageInsightEnable
    are
    True
    , 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.
使用
get-meta-query-status
命令检查MetaQuery状态:
bash
aliyun ossutil api get-meta-query-status --bucket <your-bucket-name> --output-format json --user-agent AlibabaCloud-Agent-Skills
根据返回的状态处理:
  • 状态为
    Deleted
    :MetaQuery正在关闭中,请用户稍后重试
  • 状态为
    Running
    Ready
    :MetaQuery已创建,检查以下两个条件:
    • MetaQueryMode
      是否为
      semantic
    • WorkflowParameters
      是否包含以下配置:
      xml
      <WorkflowParameters>
        <WorkflowParameter><Name>ImageInsightEnable</Name><Value>True</Value></WorkflowParameter>
        <WorkflowParameter><Name>VideoInsightEnable</Name><Value>True</Value></WorkflowParameter>
      </WorkflowParameters>
    如果
    MetaQueryMode=semantic
    VideoInsightEnable
    ImageInsightEnable
    均为
    True
    ,说明用户已成功开启带内容感知的向量模式MetaQuery(可大幅提升语义搜索质量),无需进一步操作。如果不满足上述条件,建议用户切换到其他Bucket重新操作。

Task 3: Execute Semantic Search

任务3:执行语义搜索

Prerequisites for MetaQuery Search

MetaQuery搜索前置要求

Before using MetaQuery for search, confirm the following:
  1. Verify MetaQuery is enabled:
    bash
    aliyun ossutil api get-meta-query-status --bucket <your-bucket-name> --output-format json --user-agent AlibabaCloud-Agent-Skills
  2. If MetaQuery is not enabled: Complete the enablement process first. Refer to Task 2 to enable it using the Python script.
  3. Check index scan status: The
    Phase
    field from
    get-meta-query-status
    indicates the current scan phase:
    • FullScanning
      : Full scan in progress. Search is not available yet. Wait for the full scan to complete.
    • IncrementalScanning
      : Incremental scan in progress. The index has been largely built and search can be performed normally.
  4. Verify MetaQuery state is
    Running
    : MetaQuery is only available when
    State
    is
    Running
    . If the state is
    Ready
    or any non-
    Running
    state, you may need to wait or re-enable it.
1. Prepare the meta-query.xml file: Create a
meta-query.xml
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):
xml
<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
meta-query.xml
file defines the query conditions, and search results return the most similar files.
bash
aliyun ossutil api do-meta-query --bucket <bucket-name> --meta-query file://meta-query.xml --meta-query-mode semantic --user-agent AlibabaCloud-Agent-Skills
For scalar search, use
--meta-query-mode basic
For 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
x-oss-process
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.
Video 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-Skills
Parameters:
t_0
: Capture frame at 0ms as cover;
f_png
: Output format PNG;
w_0,h_0
: Width/height 0 means original resolution.
Image files -- Get image preview link:
bash
aliyun ossutil presign oss://<bucket-name>/<image-object-key> --user-agent AlibabaCloud-Agent-Skills
Note: The
aliyun ossutil presign
command 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 via
x-oss-process
(e.g., resize, crop):
bash
aliyun ossutil presign oss://<bucket-name>/<image-object-key> --query-param x-oss-process=image/resize,w_200 --user-agent AlibabaCloud-Agent-Skills
This generates a thumbnail preview to reduce loading time.
使用MetaQuery进行搜索前,需确认以下内容:
  1. 验证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.xml
文件定义查询条件,搜索结果返回最匹配的文件。
bash
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
参数说明:
t_0
:取0毫秒处的帧作为封面;
f_png
:输出格式为PNG;
w_0,h_0
:宽高为0代表使用原始分辨率。
图片文件 -- 获取图片预览链接:
bash
aliyun ossutil presign oss://<bucket-name>/<image-object-key> --user-agent AlibabaCloud-Agent-Skills
注意
aliyun ossutil presign
命令生成的是签名临时访问URL,有效期内可直接在浏览器打开预览。对于图片文件,还可以通过
x-oss-process
添加图片处理参数(例如缩放、裁剪):
bash
aliyun 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.,
VideoInsightEnable
or
ImageInsightEnable
is not
True
in
WorkflowParameters
), possible reasons include:
  • The file's metadata index has not been fully built yet. Wait for the index scan to complete (check the
    Phase
    field via
    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
    Phase
    field via
    aliyun ossutil api get-meta-query-status --bucket <bucket-name> --output-format json --user-agent AlibabaCloud-Agent-Skills
    :
    • FullScanning
      : The overall index is still in full scan mode. Wait patiently.
    • IncrementalScanning
      : Newly uploaded files are being processed incrementally. Usually wait a few minutes.
  • 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未启用内容感知(即
WorkflowParameters
中的
VideoInsightEnable
ImageInsightEnable
不为
True
),可能的原因包括:
  • 文件的元数据索引尚未构建完成,请等待索引扫描完成(通过
    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-Skills
For 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
undefined
bash
undefined

Close 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脚本部分。