Atlas Kubernetes Operator支持Atlas集群上的Atlas Search索引。要学习;了解详情,请参阅管理MongoDB搜索索引。
先决条件
- 在部署 Atlas Kubernetes Operator 的情况下运行 Kubernetes 集群。 
- 任何集群层上的 MongoDB 版本 - 4.2或更高版本。- 注意- 您创建的内容不能超过: - 在 - M0集群上具有 3 个索引。
- M2集群上有 5 个索引。
- M5集群上有 10 个索引。
 - 您可以在 - M10+集群上创建的索引数量没有限制。
- 用于创建 Atlas Search 索引的集合。 
必需的访问权限
您必须具有以下角色之一才能创建 Atlas Search 索引:
在要创建索引的数据库中,您必须至少拥有 readWriteAnyDatabase 角色或  readWrite 访问权限。要了解更多信息,请参阅角色和权限概述或内置角色和继承的权限。
步骤
配置 AtlasSearchIndexConfig 自定义资源。
以下示例显示了为lucene.standard分析器方法配置的AtlasSearchIndexConfig自定义资源规范。
注意
多个 atlasDeployment 自定义资源可以引用相同的 atlasSearchIndexConfiguration 自定义资源。
示例:
运行以下命令:
cat <<EOF | kubectl apply -f - apiVersion: atlas.mongodb.com/v1 kind: AtlasSearchIndexConfig metadata:   name: atlassearchindexconfig-sample   namespace: mongodb-atlas-system spec:   analyzer: lucene.standard   searchAnalyzer: lucene.standard EOF 
要了解可用参数的更多信息,请参阅 AtlasSearchIndexConfig 自定义资源。
配置 AtlasDeployment 自定义资源。
配置 spec.deploymentSpec.searchIndexes 对象。
以下参数应用于该对象:
| Parameter | 说明 | 
|---|---|
| 
 | 人类可读标签,用于标识包含具有一个或多个 Atlas Search 索引的集合的现有数据库。 重要提示:您指定的数据库必须已经存在。 如果您没有现有数据库,请创建一个。 | 
| 
 | 可读标签,用于标识包含一个或多个 Atlas Search 索引的集合。 | 
| 
 | 索引的类型。Atlas 接受以下值: 
 | 
| 
 | |
| 
 | 包含  | 
要了解可用参数的更多信息,请参阅 AtlasDeployment 自定义资源。
示例:
运行以下命令。
cat <<EOF | kubectl apply -f - apiVersion: atlas.mongodb.com/v1 kind: AtlasDeployment metadata:   name: my-atlas-cluster   namespace: mongodb-atlas-system spec:   projectRef:     name: my-project   deploymentSpec:     backupEnabled: true     clusterType: REPLICASET     name: Test-cluster-M10     replicationSpecs:     - regionConfigs:       - backingProviderName: AWS         electableSpecs:           instanceSize: M10           nodeCount: 3         priority: 7         providerName: AWS         regionName: US_EAST_1       zoneName: Zone 1     searchIndexes:     - DBName: sample_airbnb       collectionName: listingsAndReviews       name: my-index       search:         mappings:           dynamic: true         searchConfigurationRef:           name: atlassearchindexconfig-sample           namespace: mongodb-atlas-system       type: search     terminationProtectionEnabled: false EOF