The World’s Largest Online Community for Developers
I have written below code, it is working for the one word but when I give the seq variable term I am not getting the output, can anyone tell me how to solve this.
val term = List("Achieving","Making") val sc = new SparkContext("local[*]","Filter_lines") val Lines = sc.textFile("../book.txt") val filter_Lines = Lines.filter(l => l.contains("Making")).collect() filter_Lines.foreach(println)
Try this -
Lines.filter(l => term.exists(t => l.contains(t))).foreach(println)
exists function on the collection accepts a function that returns true if the "l" contains any of the "t" terms.