I need to save xml files to Elasticsearch, for that I need to convert the xml file to json file to save it to Elasticsearch.
How can I do the job using Scala.
here is my code
import org.apache.spark.{SparkConf, SparkContext}
import org.apache.spark.sql.SQLContext
import org.elasticsearch.spark.sql._
object testxml {
def main(args: Array[String]): Unit = {
val conf = new SparkConf().setAppName("testxml").setMaster("local[*]")
val sc= new SparkContext(conf)
val sqlContext = new SQLContext(sc)
val df = sqlContext.read
.format("com.databricks.spark.xml")
.option("rowTag", "callrecord")
.load("/home/aymenstien/Bureau/aymen/jsonfiles/VOICE CDR.xml")
//df.printSchema()
val jsonfile = df.toJSON
jsonfile.saveToEs(“xmltest123/people”)
}
I am getting this Error
Exception in thread “main” java.lang.NoSuchMethodError: org.apache.spark.sql.types.DecimalType$.Unlimited()Lorg/apache/spark/sql/types/DecimalType;