Atlas Kubernetes Operator supports Atlas Search indexes on Atlas clusters. To learn more see Manage MongoDB Search Indexes.
Prerequisites
Running Kubernetes cluster with Atlas Kubernetes Operator deployed.
MongoDB version
4.2or higher on any cluster tier.Note
You can't create more than:
3 indexes on
M0clusters.10 indexes on Flex clusters.
There are no limits to the number of indexes you can create on
M10+clusters.Collection to create the Atlas Search index for.
Required Access
You must have one of the following roles to create Atlas Search indexes:
You must have at least the readWriteAnyDatabase role or readWrite access to the database where you want to create the indexes. To learn more, see Roles and Privileges Overview or Built-in Roles and Inherited Privileges.
Procedure
Configure an AtlasSearchIndexConfig Custom Resource.
The following example shows an AtlasSearchIndexConfig custom resource specification configured for the lucene.standard analyzer method.
Note
Multiple atlasDeployment custom resources can reference the same atlasSearchIndexConfiguration custom resource.
Example:
Run the following command:
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
To learn more about the available parameters, see AtlasSearchIndexConfig Custom Resource.
Configure the AtlasDeployment Custom Resource.
Configure the spec.deploymentSpec.searchIndexes object.
The following parameters apply to this object:
Parameter | Description |
|---|---|
| Human-readable label that identifies the existing database that contains the collection with one or more Atlas Search indexes. IMPORTANT: The database that you specify must already exist. If you don't have an existing database, create one. |
| Human-readable label that identifies the collection that contains one or more Atlas Search indexes. |
| Type of the index. Atlas accepts the following values:
|
| Name that references the |
| Namespace that contains the |
To learn more about the available parameters, see AtlasDeployment Custom Resource.
Example:
Run the following command.
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