Thanks everyone for the help. This my final version
def list_items(%{matching: name}) when is_binary(name) do
Item
# |> where([m], ilike(m.name, ^"%#{name}%"))
|> search(name)
|> Repo.all()
end
defp search(_query, name) do
query = from(query in Item)
query
|> where([t], ilike(t.name, ^"%#{name}%"))
end


















