I am getting error at yellow marked line as type mismatch; found : String ⇒ fitch required: org.bson.Document ⇒ ?
Hi Pooja,
This is because your variable dataRDD contains org.bson.Document instead of String . See also BSON.Documents for extra information.
As an example, you could try below:
case class Example(child_id:String, member_id: Int)
def parseData(doc:Document): Example={
Example(doc.get("child_id").toString,
doc.get("member_id").asInstanceOf[Number].intValue)
}
val newrdd = rdd.map(parseData)
I am new in mongodb-spark. I am trying to use Spark Graphx to process data.
You may also find the example on this post Spark Mongo Connector - GraphX useful.
Regards,
Wan.
val vertices = newrdd.map(Example => (“child_id”, “child_name”))
when i try to print vertices i am getting output as below. not getting actual result.
Hi Pooja,
This is because you have assigned string child_id and child_name for every Example object in the RDD.
If you’re trying to retrieve the value of child_id and child_nam instead, you could try as below example:
val vertices = newrdd.map(x=> (x.child_id, x.child_name));
If you have further questions on Apache Spark or Scala questions, I would recommend to post a question on StackOverflow to reach wider audience.
Best regards,
Wan.