为了方便技术交流,特建了一个交流群。
欢迎来一场技术的博弈!
//spark-sql es
package com.sparkes
import org.apache.spark.sql.SparkSession
import org.elasticsearch.spark.sql._
object WriteEs {
def main(args: Array[String]): Unit = {
val spark = SparkSession.builder()
.appName("ddd")
.master("spark://192.168.20.95:7077")
.config("es.nodes","127.0.0.1:32769")
.config("es.nodes.wan.only","true")
.config("es.nodes.discovery","false")
.config("es.index.auto.create","true")
.enableHiveSupport()
.getOrCreate()
import spark.implicits._
val data = spark.read
.option("inferSchema",true)
.option("nullValue","#")
.option("header",true)
.csv("/data/user_log.csv")
// data.repartition(3).registerTempTable("userlog")
// spark.sql("create table userlogs as select * from userlog")
data.saveToEs("spark/userlogs")
}
}