采样和验证文档

发布 /groups/{groupId}/apps/{appId}/services/{datasourceId}/commands/validate_documents

查询集合中文档的子集,并根据模式验证每个匹配项。

路径参数

application/json

body 必需

  • database_name 字符串 必需

    包含要验证集合的数据库的名称。

  • collection_name 字符串 必需

    要验证的集合名称。

  • from_schema 对象 必需

    用于验证采样文档的 EJSON 模式。

  • 查询 对象

    与集合中的文档匹配的 MongoDB 查询。运行此查询的结果是样本总体。使用此选项可将样本范围缩小到集合中文档的子集。

    默认值为 {}(空)。

  • limit 数字

    要采样的最大文档数。

    默认值为10000

  • sort 对象

    集合的 MongoDB 排序。使用它来确定要从范围查询的哪一端开始采样。

    默认值为 {}(空)。

响应

POST /groups/{groupId}/apps/{appId}/services/{datasourceId}/commands/validate_documents
curl \
 --request POST 'https://services.cloud.mongodb.com/api/admin/v3.0/groups/{groupId}/apps/{appId}/services/{datasourceId}/commands/validate_documents' \
 --header "Authorization: Bearer $ACCESS_TOKEN" \
 --header "Content-Type: application/json" \
 --data '{"database_name":"string","collection_name":"string","from_schema":{},"query":{},"limit":10000,"sort":{}}'
请求示例
{
  "database_name": "string",
  "collection_name": "string",
  "from_schema": {},
  "query": {},
  "limit": 10000,
  "sort": {}
}
响应示例 (200)
{
  "errors": [
    {
      "error_code": "false",
      "error_count": 42.0,
      "field": "(root)._id",
      "failed_ids": [
        "string"
      ],
      "failed_documents_query": {}
    }
  ],
  "total_processed_count": 42.0,
  "total_error_count": 42.0
}