For indexing, MongoDB Search counts each document as a single index object when it isn't nested inside another document. For embedded documents, MongoDB Search counts each embedded document as additional index objects depending on the number of levels of nesting. MongoDB Search stops replicating changes for indexes larger than 2,100,000,000 index objects.
If you deployed MongoDB Search on separate search nodes, you can increase the
number of MongoDB Search index objects by partitioning your index. By
default, MongoDB Search supports one partition per shard. Each partition supports
up to 2 billion index objects. You can create an index with up to four
(4) partitions by using the numPartitions option. These
partitions represent a single index with support for up to 8B documents
per cluster or shard.
When you configure partitions for your index, MongoDB Search automatically distributes the index objects between the partitions in an optimal way. When you run queries against a collection with index partitions, MongoDB Search scatters the queries to all the partitions and gathers the search results and metadata to sort, merge, and return the results.
We recommend partitioning your index when:
Your index objects reach 50% of the total limit.
The number of documents in your collection reaches two billion.
Your index will contain up to eight billion documents.
Your index is in the
STALEstate because MongoDB Search stopped replication.
When you configure partitions or modify the number of partitions, MongoDB Search triggers a rebuild of your index.
If you have more than one partition in your cluster, you can't
remove all the search nodes and migrate to a deployment model where both
the mongod and mongot processes run on the same node.
Syntax
1 { 2 "numPartitions": <integer> 3 }
Supported Values
The MongoDB Search numPartitions option takes the following values:
1- to create a single index, with no additional partitions. This is the default value.2- to create up to two partitions for up to four billion documents.4- to create up to four partitions for up to eight billion documents.
Example
The following index example uses the sample_mflix.movies collection
to demonstrate how to configure up to 4 partitions for the data in
the collection. You can use the Visual Editor or the JSON Editor in
the Atlas UI and other supported clients to create the index.