Reputation: 11
I currently search for multiple words in a string like this:
select name from restaurant where regexp_split_to_array(lower(name), '\s+') @> array['bar', 'food'];
Which splits the string in an array like this: The Food Bar = [the, food, bar]
But it only works if the full words are in the string. I want to get the same result if I use "ba" and "foo" for example. How can I achieve it?
Upvotes: 0
Views: 1827
Reputation: 246153
Full text search may do the trick:
WHERE to_tsvector('simple', name) @@ to_tsquery('simple', 'the:* | food:* | bar:*')
Upvotes: 3