Find instance by name where query is any part of its name, Grails

118 views Asked by At

In Java, the string search by its' substring goes like this:

String string = "Madam, I am Adam";
b = string.matches("(?i).*i am.*");

How to find an instance in Grails by name where query is any part of its name?

1

There are 1 answers

0
ConnorWGarvey On BEST ANSWER

I think this is what you're looking for

DomainClass.findByNameIlike("%i am%")

That is a case insensitive search for any record with name containing "I am". This is not an efficient way to query a database, so if your application will experience any kind of load, you should use it sparingly.

Edit: Documentation