How to search an array of words in a text field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2022 07:32 PM
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?
- Labels:
-
Array
-
SQL
-
Text Field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2023 12:17 AM
A simple way
select FIELD_TEXT from TABLE 1 where FIELD_TEXT like 'italia' OR FIELD_TEXT like 'mex' OR FIELD_TEXT like 'coke'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2024 11:04 PM
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

