Shopping cart uses following query for searching products:
select ...
from toode,yksus7,artliik,artryhm
where toode.nimetus ilike '%'||{{5}}||'%' escape '!'
or toode.toode ilike '%'||{{5}}||'%' escape '!'
or toode.analoog ilike '%'||{{5}}||'%' escape '!'
or yksus7.nimetus ilike '%'||{{5}}||'%' escape '!'
or artliik.artlnimi ilike '%'||{{5}}||'%' escape '!'
or artryhm.nimetus ilike '%'||{{5}}||'%' escape '!'
or toode.markused ilike '%'||{{5}}||'%' escape '!'
...
search field types are character(n) and TEXT
{{5}}
represents search term entered by user into search box in web page.
This query words only exact matches.
Texts from diffrent tables toode,yksus7,artliik,artryhm
joined in WHERE clause needs searched and best matching results returned.
If User types
blank pencil
query does not found records containing text with words not ix exact order like
pencil black
How to fix this so that similar results are also returned ? PostgreSql versions starting from 9.1 are used.