I need to do a search based on various criteria.

1. if a name contains the specified string.
2. if the name contains the specified string and a string from a list.
3. if the name contains one of the strings from a list.

I have the following code but it doesn't work. How bad is this code?

```
def taskList = Object.createCriteria().list(params) {
if (params.query) {
    ilike("name", "%${params.query}%")
}
if (params.nameList) {
    params.nameList.split("&").each {
            or {
              ilike("name", "%${it}$%")
            }
    }
    }

```

The result is empty for use cases 2 & 3. What am I doing wrong? How should I do it?

Cheers