Hi fellas,
I'm developing a simple articles website in brazilian portuguese language. The search feature is based on a full-text search, but it isn't returning expected results.
I made this on postgresql. Here is the simplified table:
Artigos
-id
-title -- article title
-intro -- article introduction
-content -- article body
-publishdate -- date of launch
-artigosts -- this will work as our fts index.
After creating the table, I ran:
UPDATE artigos SET artigosts =
setweight(to_tsvector('pg_catalog.portuguese', coalesce(title,'')), 'A') ||
setweight(to_tsvector('pg_catalog.portuguese', coalesce(intro,'')), 'B') ||
setweight(to_tsvector('pg_catalog.portuguese', coalesce(content,'')), 'C');
CREATE INDEX artigosts_idx ON artigos USING gist (artigosts);
CREATE TRIGGER artigosts_tg
BEFORE INSERT OR UPDATE ON artigos
FOR EACH ROW EXECUTE PROCEDURE
tsvector_update_trigger('artigosts', 'pg_catalog.portuguese', 'title', 'intro', 'content');
Yes, I intend to use simple weightning on the searches. Made a index to speed up, a trigger, so I can insert and update without worry about remaking index and so on.
Well, per my understanding, it is everything fine. But results aren't. A simple example.
Let's say I have "... banco de dados ... no banco ... " as one article content. When I do:
SELECT title, intro, content FROM artigos WHERE plainto_tsquery('banco de dados') @@ artigosts;
It returns an empty set. I checked the ts_vector column and saw the predicates 'banc' and 'dad'. But I still can't understand why it does not return the row containing the mentioned article.
Can someone bring a light into this question?