Docs Menu
Docs Home
/ /
MongoDB Atlas Kubernetes Operator

Create an Atlas Search Index with Kubernetes

On this page

  • Prerequisites
  • Required Access
  • Procedure

Atlas Kubernetes Operator supports Atlas Search indexes on Atlas clusters. To learn more see Create an Atlas Search Index.

  • Running Kubernetes cluster with Atlas Kubernetes Operator deployed.

  • MongoDB version 4.2 or higher on any cluster tier.

    Note

    You can't create more than:

    • 3 indexes on M0 clusters.

    • 5 indexes on M2 clusters.

    • 10 indexes on M5 clusters.

    There are no limits to the number of indexes you can create on M10+ clusters.

  • Collection to create the Atlas Search index for.

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 Built-in Roles or Specific Privileges.

1

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.

2

Configure the spec.deploymentSpec.searchIndexes object.

The following parameters apply to this object:

Parameter
Description
DBName

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.

CollectionName
Human-readable label that identifies the collection that contains one or more Atlas Search indexes.
Type

Type of the index. Atlas accepts the following values:

  • search

  • vectorSearch

search.searchIndexConfigurationRef.name
search.searchIndexConfigurationRef.namespace
Namespace that contains the AtlasSearchIndexConfig Custom Resource.

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

Back

Data Federation

Next

Atlas Vector Search