MongoDB/mongodb-docs huggingface dataset:
# Compound Indexes

## Overview

Compound indexes hold references to multiple fields within a collection's documents, improving query and sort performance.

### Sample Data

The examples in this guide use the `sample_mflix.movies` collection from the Atlas sample datasets. To learn how to create a free MongoDB Atlas cluster and load the sample datasets, see the Get Started with PyMongo.

## Create a Compound Index

The following example creates a compound index on the `type` and `genre` fields:

```python
movies.create_index([("type", pymongo.ASCENDING), ("genre", pymongo.ASCENDING)])
```

The following is an example of a query that uses the index created in the preceding code example:

```python
query = { "type": "movie", "genre": "Drama" }
sort = [("type", pymongo.ASCENDING), ("genre", pymongo.ASCENDING)]

cursor = movies.find(query).sort(sort)
```

For more information, see Compound Indexes in the MongoDB Server manual.
# About MongoDB Documentation

The MongoDB Manual contains comprehensive documentation on MongoDB. This page describes the manual's licensing, editions, and versions, and describes how to make a change request and how to contribute to the manual.

## License

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States License

© MongoDB, Inc. 2008-2022

## Man Pages

In addition to the MongoDB Manual, you can access the MongoDB Man Pages, which are also distributed with the official MongoDB Packages.

## Version and Revisions

This version of the manual reflects version 7.0 of MongoDB.

See the MongoDB Documentation Project Page for an overview of all editions and output formats of the MongoDB Manual. You can see the full revision history and track ongoing improvements and additions for all versions of the manual from its GitHub repository.

The most up-to-date, current, and stable version of the manual is always available at "https://www.mongodb.com/docs/manual/".

## Report an Issue or Make a Change Request

To report an issue with this manual or to make a change request, file a ticket at the MongoDB DOCS Project on Jira.

## Contribute to the Documentation

The entire documentation source for this manual is available in the mongodb/docs repository, which is one of the MongoDB project repositories on GitHub.

To contribute to the documentation, you can open a GitHub account, fork the mongodb/docs repository, make a change, and issue a pull request.

In order for the documentation team to accept your change, you must complete the MongoDB Contributor Agreement.

You can clone the repository by issuing the following command at your system shell:

```bash
git clone git://github.com/mongodb/docs.git
```

### About the Documentation Process

The MongoDB Manual uses Sphinx, a sophisticated documentation engine built upon Python Docutils. The original reStructured Text files, as well as all necessary Sphinx extensions and build tools, are available in the same repository as the documentation.

For more information on the MongoDB documentation process, see the Meta Documentation.

If you have any questions, please feel free to open a Jira Case.
# Backup and Restore Sharded Clusters

The following tutorials describe backup and restoration for sharded clusters:

To use `mongodump` and `mongorestore` as a backup strategy for sharded clusters, you must stop the sharded cluster balancer and use the `fsync` command or the `db.fsyncLock()` method on `mongos` to block writes on the cluster during backups.

Sharded clusters can also use one of the following coordinated backup and restore processes, which maintain the atomicity guarantees of transactions across shards:

- MongoDB Atlas

- MongoDB Cloud Manager

- MongoDB Ops Manager

Use file system snapshots back up each component in the sharded cluster individually. The procedure involves stopping the cluster balancer. If your system configuration allows file system backups, this might be more efficient than using MongoDB tools.

Create backups using `mongodump` to back up each component in the cluster individually.

Limit the operation of the cluster balancer to provide a window for regular backup operations.

An outline of the procedure and consideration for restoring an *entire* sharded cluster from backup.