Stratio / Spark-MongoDB

Spark library for easy MongoDB access
http://www.stratio.com
Apache License 2.0
307 stars 96 forks source link

How to save DataFrame into MongoDB using Java API? #143

Open NiranjanMudhiraj opened 8 years ago

lizengfa commented 8 years ago

I want to know also:)I use mongo-hadoop-core to save MongoDB now

darroyocazorla commented 8 years ago

Hi @NiranjanMudhiraj @lizengfa

You can create a MongodbDataFrame, and then, save it indicating the config. This is the source code:

class MongodbDataFrame(dataFrame: DataFrame) extends Serializable {

  /**
   * It allows storing data in Mongodb from some existing SchemaRDD
   * @param config MongoDB configuration object
   * @param batch It indicates whether it has to be saved in batch mode or not.
   */
  def saveToMongodb(config: Config, batch: Boolean): Unit = {
}

I hope it helps