爲了方便技術交流,特建了一個交流羣。node
歡迎來一場技術的博弈!sql
//spark-sql es
package com.sparkesapache
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")
}app
}elasticsearch