Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to add @ to postgres hibernate dialect?

We have a native query for full text search that uses a GIN index like so:

CREATE INDEX idx_column1 ON table1 USING gin (to_tsvector('english', column1));

SELECT *
FROM table1
where to_tsvector('english', column1) @@ to_tsquery('searchedText')

However, we were unable to replicate this query in HQL, because hibernate errors on symbol @. How to add symbol @ to the hibernate dialect?

like image 241
zhmaksat Avatar asked Nov 02 '22 17:11

zhmaksat


1 Answers

you can find it in this link, that link will guide you to :

  • recognize that SQLFunctions have to return a value and when used in HQL must be in an expression form (e.g., fts(body, 'dog') = true -- fts(body, 'dog') won't work in HQL)
  • create a Hibernate SQLFunction for PG FTS; and
  • remember that the expression "to_tsvector(body) @@ to_tsquery('dog')" evaluates to a boolean
like image 101
Angga Avatar answered Nov 09 '22 09:11

Angga