pg_search icon indicating copy to clipboard operation
pg_search copied to clipboard

Problem with query started with a number

Open sirtaylor88 opened this issue 5 years ago • 1 comments

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.

sirtaylor88 avatar Nov 26 '19 11:11 sirtaylor88

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.

sqbell avatar Dec 10 '20 12:12 sqbell