If you don’t see all the fields you expect to in the Replication Key field for you Mongo integration, the root cause may be insufficient permissions or a lack of field indexing.

Replication Key Requirements

Stitch uses a field you define - called a Replication Key - to identify new and updated data for replication. For Mongo connections, Stitch requires that the Replication Key field:

  1. be indexed, AND
  2. exist in the root of the document.

If you want to sync Mongo data and are going to add query parameters - which is what Incremental Replication does - undue stress could be put on your Mongo database. By indexing the fields you want to sync, that stress can be relieved.

There are also some other considerations around Mongo Replication Keys, which you can read about in the Selecting & Changing Mongo Replication Keys guide.

Detecting Fields for Use as Replication Keys

Stitch uses the listIndexes command to find fields that you can use for Incremental Replication. This means:

  • If the Stitch user doesn’t have permissions to run this command on a specified collection OR
  • The field you want to use isn’t indexed

Stitch will only be able to display the _id field in the Replication Key selection field.

If the collection is append-only, this may be perfectly fine.

If the collection isn’t append-only, another field may be needed. We recommend reviewing the Selecting & Changing Mongo Replication Keys guide for help selecting an appropriate Replication Key.

Next Steps

  1. Verify that the Stitch Mongo user has all the required permissions as outlined in the Mongo connection instructions.
  2. Verify that the field you want to use is indexed.
  3. Verify that the field you want to use as a Replication Key exists in the root of the document.

Note that it may take some time for Stitch to detect and process these changes after you’ve applied them. We recommend waiting for a replication cycle to complete before reaching out to support.

Contacting Support

If you’ve done all of the above, a full replication cycle has completed, and the field still hasn’t shown up in the Replication Key field, please reach out to support.

Questions? Feedback?

Did this article help? If you have questions or feedback, please reach out to us.