spark on es 多索引查询

核心接口

trait SparkOnEsService {
  val conf = new SparkConf
//  conf.setMaster("local[10]")
  val file = new File("lib").getCanonicalFile.listFiles()
  val fs = file.toSeq.map(f => {
    f.getAbsolutePath
  })
  conf.setJars(fs)
  conf.setAppName("spark_sql_on_es")
  val sqlContext = SparkSession.builder().config(conf).getOrCreate()
  val options = Map("pushdown" -> "true", "es.nodes" -> "ip", "es.port" -> "prot")
  valt1 = sqlContext.read.format("org.elasticsearch.spark.sql").options(options).load("index/index_type")
  val t2 = sqlContext.read.format("org.elasticsearch.spark.sql").options(options).load("index/index_type")
  t1.createTempView("v1")
  t2.createTempView("v2")
  def excutor(sql: String): DataResult
}

 

posted @ 2018-03-24 17:05  wq920  阅读(1483)  评论(0编辑  收藏  举报