cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to search an array of words in a text field

183530
New Contributor III

Example:

TABLE 1

FIELD_TEXT

I like salty food and Italian food

I have Italian food

bread, rice and beans

mexican foods

coke, sprite

array

['italia', 'mex','coke']

match TABLE1 X ARRAY

Results:

I like salty food and Italian food

I have Italian food

mexican foods

is it possible to do in sql or pyspark?

2 REPLIES 2

User16756723392
Databricks Employee
Databricks Employee

A simple way

select FIELD_TEXT from TABLE 1 where FIELD_TEXT like 'italia' OR FIELD_TEXT like 'mex' OR FIELD_TEXT like 'coke'

Meredithharper
New Contributor II

Yes, you can do it in SQL with LIKE or IN and in PySpark using array contains, ideal for filtering Words like halal catering Barcelona, catering, and many more

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group