-
Notifications
You must be signed in to change notification settings - Fork 371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Searching for email addresses #224
Comments
If PostgreSQL is treating @ as a space, then I think it should be added to our DISALLOWED_CHARACTERS array. Shouldn't be too difficult to add a few test cases and then update the implementation. I'd want to make sure queries for longer, more complete email addresses still work, because I believe the tsearch parser recognizes full email addresses. If you or anyone can make a pull request, it would be appreciated as well. I might be able to get to this soon. Otherwise Grant Hutchins
|
Hey @nertzy thanks for the quick reply. I actually did dig around (before posting above) and tried adding the '@' to DISALLOWED_CHARACTERS, but it didn't make a difference :-/ |
We just ran into this on version
Then we decided to upgrade to latest version |
@Jaco-Pretorius Does upgrading to newer PgSearch solve this for you too? |
Is there a workaround for this? I am using Postgres 9.4.4 and pg_search-1.0.5 |
I'm using pg_search 1.0.6 and Postgres 9.4. Having the same issue. If I have |
I'm still having issues with this as well using Postgres 9.4 and 1.06 |
In case anyone comes here with the same problem @danielbonnell has in the comment above The answer is that trigram search just simply does not work like that. Here is a good explanation on why it won't work. You're just going to have to use good-old |
@vinhboy I fortunately realized I didn't need
|
Here is one potential solution: https://stackoverflow.com/a/35669178 |
To solve this, I used a cached column to store tsvector on creation time where I stored results of |
@sp2410 if I try this method I get an error as soon as I try to create the column, how did you bypass that? ALTER TABLE users
ADD COLUMN searchable tsvector GENERATED ALWAYS AS (
setweight(to_tsvector('simple', regexp_split_to_array(coalesce(email,''), E'\[.@]')::text), 'A') ||
setweight(to_tsvector('simple', coalesce(last_name,'')), 'B') ||
setweight(to_tsvector('simple', coalesce(first_name,'')), 'C')
) STORED; Error:
As soon as I remove the |
PR #509 would help with this by just using a basic |
I'm trying to search for users based on either name or email address. As far as I can tell postgresql interprets the '@' symbol as a special character and breaks my search.
Here is my setup on the search:
When I pass through a query of 'user@ex' I get the following sql:
It seems like postgresql is breaking up my query at the '@' token, based on the following:
Should I be escaping my query in some way, or does pg_search simply not support searching by fields which contain an '@' symbol? (I'm guessing we would have the same problem with other 'special' characters in posgresql, such as '&', '|' or '_'.
The text was updated successfully, but these errors were encountered: