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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2025 09:24 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
08-19-2025 10:53 AM - edited 08-19-2025 10:54 AM
Yes, it’s possible to search an array of words in a text field using SQL with LIKE clauses or regex functions, while PySpark provides higher scalability with functions like rlike and array_contains (Wikipedia explains that SQL is a domain-specific language for managing relational data, while PySpark is built on Apache Spark for large-scale data processing). The choice depends on whether you need quick database queries or distributed computation for big datasets. Much like exploring variety in ihop-menus, selecting the right tool depends on scale and flexibility requirements. for more check my profile