对于 AI 代理:可在 https://www.mongodb.com/zh-cn/docs/llms.txt 获取文档索引—通过在任何 URL 路径后添加 .md 可获取所有页面的 Markdown 版本。

使用 Kubernetes 创建 Atlas Search 索引

Atlas Kubernetes Operator支持Atlas集群上的Atlas Search索引。要学习;了解更多信息,请参阅管理MongoDB搜索索引。

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

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

    注意

    您创建的内容不能超过:

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

    • 针对 Flex 集群的 10 个索引。

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

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

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

您必须至少具有要创建索引的数据库的readWriteAnyDatabase角色或读写访问权限。要学习;了解更多信息,请参阅内置角色或内置角色。

1

以下示例显示了为lucene.standard分析器方法配置的AtlasSearchIndexConfig自定义资源规范。

注意

多个 atlasDeployment 自定义资源可以引用相同的 atlasSearchIndexConfiguration 自定义资源。

示例:

运行以下命令:

cat <<EOF | kubectl apply -f -apiVersion: atlas.mongodb.com/v1kind: AtlasSearchIndexConfigmetadata: name: atlassearchindexconfig-sample namespace: mongodb-atlas-systemspec: analyzer: lucene.standard searchAnalyzer: lucene.standardEOF

要了解可用参数的更多信息,请参阅 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/v1kind: AtlasDeploymentmetadata: name: my-atlas-cluster namespace: mongodb-atlas-systemspec: 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: falseEOF
给本页内容打分