Join us Sept 17 at .local NYC! Use code WEB50 to save 50% on tickets. Learn more >
MongoDB Event
Docs 菜单
Docs 主页
/ /
MongoDB Atlas Kubernetes Operator

使用 Kubernetes 创建 Atlas Search 索引

Atlas Kubernetes Operator支持Atlas集群上的Atlas Search索引。要学习;了解详情,请参阅 管理Atlas Search索引。

  • 部署 Atlas Kubernetes Operator 的情况下运行 Kubernetes 集群。

  • 任何集群层上的 MongoDB 版本4.2 或更高版本。

    注意

    您创建的内容不能超过:

    • M0 集群上具有 3 个索引。

    • M2 集群上有 5 个索引。

    • M5 集群上有 10 个索引。

    您可以在 M10+ 集群上创建的索引数量没有限制。

  • 用于创建 Atlas Search 索引的集合。

您必须具有以下角色之一才能创建 Atlas Search 索引:

在要创建索引的数据库中,您必须至少拥有 readWriteAnyDatabase 角色或 readWrite 访问权限。要了解更多信息,请参阅角色和权限概述内置角色和继承的权限

1

以下示例显示了为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 自定义资源。

2

配置 spec.deploymentSpec.searchIndexes 对象。

以下参数应用于该对象:

Parameter
说明

DBName

人类可读标签,用于标识包含具有一个或多个 Atlas Search 索引的集合的现有数据库。

重要提示:您指定的数据库必须已经存在。 如果您没有现有数据库,请创建一个。

CollectionName

可读标签,用于标识包含一个或多个 Atlas Search 索引的集合。

Type

索引的类型。Atlas 接受以下值:

  • search

  • vectorSearch

search.searchIndexConfigurationRef.name

search.searchIndexConfigurationRef.namespace

要了解可用参数的更多信息,请参阅 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

后退

Data Federation

在此页面上