title: Where clause with function causing "is not a valid query expression"
body: <p>I have this working query:</p>
  
  <pre><code>  products_shops_categories = from p in Product,
    join: ps in ProductShop, on: p.id == ps.p_id,
    join: s in Shop, on: s.id == ps.s_id,
    join: pc in ProductCategory, on: p.id == pc.p_id,
    join: c in Subcategory, on: c.id == pc.c_id,
    where: c.id in ^categories,
    where: s.id in ^shop_ids,
    select: [p, c, s]
  </code></pre>
  
  <p>I just want to add in one more <code>where</code> clause, to account for <code>keywords</code>. EG if the user entered some keywords, only return products if the keywords are in either the product name or product brand. </p>
  
  <p>My attempt:</p>
  
  <pre><code>def are_keywords_in_product(keywords, product) do
    IO.inspect(product)
    Enum.map(keywords, fn(keyword) -&gt; 
      product.name =~ keyword || product.brand =~ keyword
    end)
  end
  
  def create_query(keywords, categories, shop_ids) do
    products_shops_categories = from p in Product,
    join: ps in ProductShop, on: p.id == ps.p_id,
    join: s in Shop, on: s.id == ps.s_id,
    join: pc in ProductCategory, on: p.id == pc.p_id,
    join: c in Subcategory, on: c.id == pc.c_id,
    where: c.id in ^categories,
    where: s.id in ^shop_ids,
    where: are_keywords_in_product(keywords, p), 
    select: [p, c, s]
  end
  
  def create_query(nil, categories, shop_ids) do
    products_shops_categories = from p in Product,
    join: ps in ProductShop, on: p.id == ps.p_id,
    join: s in Shop, on: s.id == ps.s_id,
    join: pc in ProductCategory, on: p.id == pc.p_id,
    join: c in Subcategory, on: c.id == pc.c_id,
    where: c.id in ^categories,
    where: s.id in ^shop_ids,
    select: [p, c, s]
  end
  
      ......create_query(keywords, categories, shop_ids) |&gt; Api.Repo.all
  </code></pre>
  
  <p>Effectively my last <code>where</code> clause in <code>create_query(keywords)</code> should return true if the keywords are in the product name or brand (I might need to try and return false instead of nothing, if keywords not found in product?). </p>
  
  <p>I'm getting this error:</p>
  
  <pre><code>== Compilation error on file lib/api/router.ex ==
  ** (Ecto.Query.CompileError) `are_keywords_in_product(keywords, p)` is not a valid query expression.
  
  * If you intended to call a database function, please check the documentation
    for Ecto.Query to see the supported database expressions
  
  * If you intended to call an Elixir function or introduce a value,
    you need to explicitly interpolate it with ^
  
      expanding macro: Ecto.Query.where/3
      lib/api/router.ex:169: Api.Router.create_query/3
      expanding macro: Ecto.Query.select/3
      lib/api/router.ex:169: Api.Router.create_query/3
      expanding macro: Ecto.Query.from/2
      lib/api/router.ex:169: Api.Router.create_query/3
  </code></pre>
  
  <p>How do I get rid of the error?</p>