Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Is it possible to use Criteria API to query with Postgres functions such as to_tsquery and to_tsvector? #825

Open
Assignees
Labels
for: team-attentionAn issue we need to discuss as a team to make progress status: waiting-for-triageAn issue we've not yet triaged
@mindy-jump

Description

I am trying to implement full text search to one of my apis, here's an example postgres sql query:

SELECT *
FROM recipes
WHERE to_tsvector('english', description || ' ' || name @@ to_tsquery('english', 'uni:*'); 

I've attempted to try and do the below within the code but noticed the where clause is only Critera.CriteriaStep type and needs to be chained with some operator to make it a Criteria:

Criteria criteria = Criteria.where("to_tsvector('english', " + VECTOR_FUNC + "@@ to_tsquery('english', 'sec:*');");
this.template
 .select(RecipeEntity.class)
 .matching(Query.query(criteria)).all();

Or would I have to do something like below? I am relatively new to using this framework and apologies if this has already gone answered.

databaseClient
 .sql("SELECT id, type FROM recipes WHERE to_tsvector('english', description || ' ' || name @@ to_tsquery('english', :searchText")
 .bind("searchText", searchText)

Metadata

Metadata

Assignees

Labels

for: team-attentionAn issue we need to discuss as a team to make progress status: waiting-for-triageAn issue we've not yet triaged

Type

No type

Projects

No projects

Milestone

No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      AltStyle によって変換されたページ (->オリジナル) /