Вопрос очень абстрактный, при условии, что содержимое загружено в RDD, а ключевые слова загружены в список, работает код ниже.
scala> val contents = sc.parallelize(Seq("this is spark.","this can be scala and spark.","this is hive."))
contents: org.apache.spark.rdd.RDD[String] = ParallelCollectionRDD[137] at parallelize at <console>:24
scala> val keywordsRdd = sc.parallelize(Seq("spark", "scala", "hive"))
keywordsRdd: org.apache.spark.rdd.RDD[String] = ParallelCollectionRDD[138] at parallelize at <console>:24
scala> val keywords:List[String] = keywordsRdd.collect.toList
keywords: List[String] = List(spark, scala, hive)
scala> val mappedData = contents.flatMap(x=>x.split(",")).map(x => (x,x.split("\\s+").last.replaceAll("[.]",""))).filter(x=> keywords.contains(x._2)).collect.foreach(println)
(this is spark.,spark)
(this can be scala and spark.,spark)
(this is hive.,hive)