Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

286
Views
syntax error in tsquery : parameter with whitespaces

I have this Full-Text-Search function:

CREATE OR REPLACE FUNCTION search_questions(psearch text)
  RETURNS TABLE (questionid INTEGER) AS $func$
BEGIN
  return QUERY
  SELECT DISTINCT (questions.publicationid)
  FROM questions
  WHERE to_tsvector(coalesce(questions.title, '')) @@ to_tsquery(psearch)
        OR
        publicationid IN (
          SELECT DISTINCT(publications.publicationid) FROM publications WHERE to_tsvector(coalesce(publications.body, '')) @@ to_tsquery(psearch)
        )
  ;
END
$func$  LANGUAGE plpgsql;

but it only works with a single word parameter. If I search for "user test", it returns

ERROR: syntax error in tsquery: "user test"

Is there any way to search for texts with whitespaces in it?

Kind regards

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

I found how to solve it. Here it goes

Replace: to_tsquery(psearch)

with: plainto_tsquery(psearch)

over 4 years ago · Santiago Trujillo Report

0

You can put single quotes around your terms and still use to_tsquery().

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!