If certain fields can be NULL, you need to apply coalesce(field, '')
on them in the global concatenation that gets the string to search into.
Otherwise it seems to work with the example values given in the comments:
select to_tsvector('english','RG147SW RG14 Greenham Road Newbury West Berkshire')
@@ plainto_tsquery('english', 'greenham road rg14');
?column?
----------
t
(1 row)
But this one won't match (the result is NULL) and this would be the case when Admin2
is NULL, or more generally any other field passed as is to the ||
operator.
select to_tsvector('english','RG147SW RG14 Greenham Road ' || NULL || ' Newbury West Berkshire')
@@ plainto_tsquery('english', 'greenham road rg14');
?column?
----------
(1 row)