0

I attempting to create a query to find the name other in my sql database. I have a basic like search as follow and would like to use a full text search instead.

Like Query

SELECT g.*, COUNT(*) OVER() AS total 
FROM group AS g 
WHERE UPPER(g.name) LIKE UPPER('oth%')

Full Text Query

SELECT g.*, COUNT(*) OVER() AS total 
FROM group AS g 
WHERE to_tsvector(g.name) @@ to_tsquery('oth:*') 

It appears that my full text returns 0 unlike my like search does. Why is this so when it appears that both queries appear to be doing similar searches

1 Answer 1

1

It looks like 'other' is in the default stop word list in english. I have tested with PostgreSQL 12 at Linux level:

$ grep other /usr/pgsql-12/share/tsearch_data/english.stop 
other

In the database:

postgres=# select to_tsvector('french','other');
 to_tsvector 
-------------
 'other':1
(1 row)

postgres=# select to_tsvector('english','other');
 to_tsvector 
-------------

(1 row)

postgres=# select to_tsvector('english','others');
 to_tsvector 
-------------
 'other':1
(1 row)

postgres=# select to_tsvector('english','another');
 to_tsvector 
-------------
 'anoth':1
(1 row)

Try 'another'.

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.