views:

300

answers:

1

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?

+6  A: 

I believe using

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

is the way you are meant to do case insensitive searches

j pimmel