pg_search
pg_search copied to clipboard
Problem with query started with a number
In my project, i need to search for reference number with format like "DEMO-2019-11-0001" in a column. I used options tsearch { prefix: true } and trigram for pg_search_scope. If I search with queries "0001" or "2019", no result is found. But if I tried "-0001", the result "DEMO-2019-11-0001" appears correctly.
Not sure if it helps, but here is why it happens: https://stackoverflow.com/a/57796505. Basically -0001
is treated as a signed integer by PostgreSQL.