Finding special characters with pg_search
I'm using
pg_search
And trying to find a special character in the title.
For example, I have two lines with this information:
id title
1 GT40
2 #GT40
So when I search for "# GT40", the result with pg_search is 1 and 2. But I want to search for the word exaccty, so the result is only 2.
Thank!
source to share
I tried to write a comment, but my reputation is not high enough yet. But is it possible what you are trying to do with pg_search
impossible?
pg_search is based on PostgreSQL full text search. Testing in the console shows that "GT40" and "# GT40" are indexed into the same token (which means your searches cannot separate them):
"GT40"
=# SELECT to_tsvector('english', 'GT40');
to_tsvector
-------------
'gt40':1
(1 row)
"# GT40"
=# SELECT to_tsvector('english', '#GT40');
to_tsvector
-------------
'gt40':1
(1 row)
Here's some background information that might be helpful:
Tutorial: http://shisaa.jp/postset/postgresql-full-text-search-part-1.html
PostgreSQL Full Text Search Reference: http://www.postgresql.org/docs/9.1/static/textsearch.html
source to share