I have about 20 million rows text data and want to label it based on several keywords (about 100k keywords). My text data was look like this
| text |
|---|
| my car was broken |
| nobody knows |
| the fish is so beautiful |
While the keywords is look like this
| keywords |
|---|
| car |
| beautiful |
| know |
| journey |
My expected output is look like this, where I will regex the text column using keywords data.
| text | keywords |
|---|---|
| my car was broken | car |
| nobody knows | know |
| the fish is so beautiful | beautiful |
I use regex like in solution of this post But, since my data is so huge (20mio x 100k keywords) it runs so long like forever. So, what I want to ask is, is there any better solution?
Anyway, here the query I use:
select 'my car was broken' as text
union all
select 'nobody knows'
union all
select 'the fish is so beautiful'
)
,raw_keywords as(
select 'car' as keyword
union all
select 'beautiful'
union all
select 'know'
union all
select 'journey'
)
SELECT text, keyword
FROM raw_text, raw_keywords
WHERE REGEXP_CONTAINS(text, keyword)



