val conf = new SparkConf().setAppName("Test02").setMaster("local[*]")
    conf.set("es.index.auto.create","true")
    conf.set("es.nodes","192.168.161.101")
    conf.set("es.port","9200")
    conf.set("es.nodes.wan.only","true")
    conf.set("es.read.field.as.array.include","array名字")//
    val spark: SparkSession = SparkSession.builder().config(conf).getOrCreate()
    val ess: DataFrame = spark.sqlContext.read.format("org.elasticsearch.spark.sql")
      .option("inferSchema", "true")
      .load("index/Type")
    ess.show(false)
Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐