Link Search Menu Expand Document Documentation Menu

常用操作

测试过程使用各种操作,这些操作位于工作负载的operations目录中。本页详细介绍了 OpenSearch 基准测试工作负载中最常见的操作。

bulk

bulk操作类型允许您将bulk请求作为任务运行。

以下示例展示了一个bulk操作类型,其bulk-size5000个文档

{
  "name": "index-append",
  "operation-type": "bulk",
  "bulk-size": 5000
}

create-index

create-index操作运行创建索引 API。它支持以下两种索引创建模式

  • 创建工作负载indices部分中指定的所有索引
  • 在操作本身中定义并创建特定索引

以下示例创建工作负载indices部分中定义的所有索引。它使用工作负载中定义的所有索引设置,但会覆盖分片数量。

{
  "name": "create-all-indices",
  "operation-type": "create-index",
  "settings": {
    "index.number_of_shards": 1
  },
  "request-params": {
    "wait_for_active_shards": "true"
  }
}

以下示例创建一个新索引,其中包含操作主体中指定的所有索引设置

{
  "name": "create-an-index",
  "operation-type": "create-index",
  "index": "people",
  "body": {
    "settings": {
      "index.number_of_shards": 0
    },
    "mappings": {
      "docs": {
        "properties": {
          "name": {
            "type": "text"
          }
        }
      }
    }
  }
}

delete-index

delete-index操作运行删除索引 API。与create-index操作一样,您可以删除工作负载indices部分中找到的所有索引,或者根据index设置中传递的字符串删除一个或多个索引。

以下示例删除工作负载indices部分中找到的所有索引

{
  "name": "delete-all-indices",
  "operation-type": "delete-index"
}

以下示例删除所有logs_*索引

{
  "name": "delete-logs",
  "operation-type": "delete-index",
  "index": "logs-*",
  "only-if-exists": false,
  "request-params": {
    "expand_wildcards": "all",
    "allow_no_indices": "true",
    "ignore_unavailable": "true"
  }
}

cluster-health

cluster-health操作运行集群健康 API,该 API 检查集群健康状态并根据为request-params设置的参数返回预期状态。如果返回意外的集群健康状态,则操作会报告失败。您可以使用 OpenSearch Benchmark execute-test命令中的--on-error选项来控制在健康检查失败时 OpenSearch Benchmark 的行为。

以下示例创建一个cluster-health操作,该操作检查任何log-*索引的green健康状态

{
  "name": "check-cluster-green",
  "operation-type": "cluster-health",
  "index": "logs-*",
  "request-params": {
    "wait_for_status": "green",
    "wait_for_no_relocating_shards": "true"
  },
  "retry-until-success": true
}

refresh

refresh操作运行刷新 API。operation不返回任何元数据。

以下示例刷新所有logs-*索引

{
 "name": "refresh",
 "operation-type": "refresh",
 "index": "logs-*"
}

search操作运行搜索 API,您可以使用它在 OpenSearch 基准测试索引中运行查询。

以下示例在search操作中运行match_all查询

{
  "name": "default",
  "operation-type": "search",
  "body": {
    "query": {
      "match_all": {}
    }
  },
  "request-params": {
    "_source_include": "some_field",
    "analyze_wildcard": "false"
  }
}
剩余 350 字符

有问题?

想贡献?