Spark + ElasticSearch returns RDD[(String, Map[String, Any])]. How can I manipulate Any?
The issue you are seeing is because the type being returned is a buffer - not a Double.
If you cast it to a Buffer you will not get the class cast exception. For example, indexing the following document in ES:
{ "myDouble" : 4.20, "myString" : "test", "myList" : [1.2, 93.2, 42.3]}
And then querying from spark:
val documents = sc.esRDD("test/test", "?q=*")val doc = documents.first()._2println(doc.get("myDouble").get.asInstanceOf[Double]) # 4.2println(doc.get("myString").get.asInstanceOf[String]) # testimport scala.collection.mutable.Bufferprintln(doc.get("myList").get.asInstanceOf[Buffer[Double]]) # Buffer(1.2, 93.2, 42.3)println(doc.get("myList").get.asInstanceOf[Buffer[Double]].mkString(","))# 1.2,93.2,42.3