1

I created an index for full text search in postgresql.

CREATE INDEX pesquisa_idx 
ON chamado 
USING 
gin(to_tsvector('portuguese', coalesce(titulo,'') || coalesce(descricao,'')));

When I run this query:

SELECT * FROM chamado WHERE to_tsvector('portuguese', titulo) @@ 'ura'

It returned to me some rows.

But when my argument is in all uppercase, no rows are returned. For example:

SELECT * FROM chamado WHERE to_tsvector('portuguese', titulo) @@ 'URA'

When the argument is 'ura' I get a few lines; when the argument is 'URA' I do not get any rows.

Why does this happen?

1 Answer 1

3

You get no matches in the second case since to_tsvector() lowercases all lexemes. Use to_tsquery() to build the query, it will take care of the case issues as well:

SELECT * FROM chamado WHERE to_tsvector('portuguese', titulo) @@ to_tsquery('portuguese', 'URA')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.