3

I'm trying to do a partial search using Hibernate Panache. I'm building a backend using Quarkus and Kotlin. Now when my frontend gives me a search string I'd like to return all partial results.

I have the following query:

repository.find("firstName LIKE '%?1%'", value)

Now I've tried a couple of variations of this, including one with the .list() method.

Does anyone know how I should handle this?

rjjdv
  • 339
  • 1
  • 3
  • 12
  • What do you mean with "partial results"? What kind of SQL query would you like to run on the db? – Davide D'Alto May 27 '22 at 17:06
  • When I search for "aar" as a first name in the users column I'd like to return all rows starting with "aar", so for example "Aaron" – rjjdv May 27 '22 at 17:10

1 Answers1

2
repository.list( "lower(firstName) LIKE ?1", value.toLowerCase() + "%" );

But if you need more complex full-text queries, I would suggest to have a look at Hibernate Search

Davide D'Alto
  • 7,421
  • 2
  • 16
  • 30