Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Case insensitive search in grails

I am developing grails application which uses file searching.For that I wrote the following code. This code works and it is gives the results with case sensitive.But I want to search files without case sensitive.

def criteria = FileDomain.createCriteria()
 def results = criteria {
    and {
      like('user', User.findById(session?.user))
      or {
        like('filename', '%' + params.fileSearchKey + '%')
        like('referenceFilename', '%' + params.fileSearchKey + '%')
         }
       }
    }

Can anyone provide help on this?

like image 302
DonX Avatar asked Mar 16 '09 01:03

DonX


2 Answers

I believe using

ilike('filename', "%${params.fileSearchKey}%")
ilike('referenceFilename', "%${params.fileSearchKey}%")

is the way you are meant to do case insensitive searches

like image 176
j pimmel Avatar answered Nov 08 '22 22:11

j pimmel


One way to do this in Grails 2.x is by using the eq node:

eq("branch", "london", [ignoreCase: true])
like image 40
Erik Pragt Avatar answered Nov 08 '22 21:11

Erik Pragt