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?
I believe using
ilike('filename', "%${params.fileSearchKey}%")
ilike('referenceFilename', "%${params.fileSearchKey}%")
is the way you are meant to do case insensitive searches
One way to do this in Grails 2.x is by using the eq node:
eq("branch", "london", [ignoreCase: true])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With