I have list of keywords
val mykeywords = Array("Glass", "Bone China", "Ceramic", "Clock")
I have dataframe
val df = Seq("Title1", "Title2", "glass", "CloCK").toDF("Title)
I want to generate dataframe
Title Flag
Title1 0
Title2 0
glass 1
CloCK 1
My Current Code
val mykeywords: Array[String] = Array("Glass", "Bone China", "Ceramic", "Clock").map(_.toLowerCase())
val df2 = df.withColumn("Flag", lower(col("Title")).rlike(mykeywords.mkString("|")).cast(IntegerType))
Which is currently not working properly for some string matches, Please point out if there is better way