Spark-MongoDB icon indicating copy to clipboard operation
Spark-MongoDB copied to clipboard

How to save DataFrame into MongoDB using Java API?

Open NiranjanMudhiraj opened this issue 8 years ago • 2 comments

NiranjanMudhiraj avatar May 30 '16 09:05 NiranjanMudhiraj

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

lizengfa avatar Jun 06 '16 07:06 lizengfa

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

darroyocazorla avatar Jun 14 '16 07:06 darroyocazorla