Data synchronization

This document is only useful for deployments where the cloud search server is used in conjunction with a mongodb database. If using the Cloud search server as a standalone database, data synchronization is of almost no importance.

The cloud search and analytics engine can be synchronized with your mongodb database automatically or manually. Automatic synchronization connects to the mongodb database, copies a snapshot of the data and then continue to sync the data by tailing the oplog of the mongodb database. For manual synchronization, you are responsible for inserting, deleting and updating data in the search engine using the CRUD api. You typically will perform manual synchronization in your app code after the object is saved in the database.

Automatic synchronization

Open the mongo shell and connect to the search server using the connection string retrieved from the task manager. You will then be able to run any of the given below commands.

Connecting via the mongo shell steps.

  • Download the mongo shell if not already installed on your machine.
  • Retrieve the connection string from the task manager using CSAS actions > Connect
  • Open the command prompt or terminal and CD to the directory in which you extracted the mongo shell files from step 1.
  • Enter the below command to connect to the search server.
    mongo -u "provide-username" -p "provide-password"
    If you have enabled SSL, use the below command.
    mongo -u "provide-username" -p "provide-password" --ssl --sslAllowInvalidCertificates

Automatic data syncing accepts only the below data tyoes from the mongo wire protocol. If an attribute is not of the type below, the attribute is ignored as if it does not exist in the source document. For almost all use cases, the below data types are more then enough. Note you can however query the data with regex types and so on. The below data type restriction is only for DML operations on automatic data synchronization.

  • Null
  • Boolean
  • Int32, Int64
  • Double
  • String, Binary
  • ObjectId
  • Datetime, Timestamp
  • Array
  • Document


Manual synchronization

Manaul synchronizations gives you complete control on the names of the classes, as well as the fields populated in the search engine but requires a bit more code to accomplish. The example given below is for parse server deployments. For meteorjs and node js, you will have to figure out when it is best to update, delete or insert into the search engine in your app code. It is generally sound practice to update the search engine once the operation has completed on the database.