I have a Dataframe containing a list of cities as following :
val cities = sc.parallelize(Seq("New York")).toDF()
Now , for each city , I would like to query Elastic and build a set of results similar to the following logic :
val cities = sc.parallelize(Seq("New York")).toDF()
cities.foreach(r => {
val city = r.getString(0)
val dfs = sqlContext.esDF("cities/docs", "?q=" + city) //returns a DataFrame which triggers the exception
})
Problem is that Spark does not allow nested operations that return dataframes. What options do I have to iterate a dataframe and get the results?