phoenix framework - Ecto where like query acts like where == -


i'm trying ecto query working this:

def find(searchterm)   query = c in contact,    #where: fragment("? % ?", c.company_name, ^searchterm),   where: like(c.company_name, ^searchterm),   contacts = repo.all(query)   {:ok, contacts} end 

in table, have company_name "asymptote". using where: like/2 query looks this:

select c0."id", c0."company_id", c0."company_name" "contacts" c0 (c0."company_name" $1) ["asym"] (1.0ms) 

when pg_trm search uncommented, looks this:

select c0."id", c0."company_id", c0."company_name" "contacts" c0 (c0."company_name" % $1) ["asym"] (1.0ms) 

as far can see, queries good, there no results. since added index after adding "asymptote" database, expect why isn't found in pg_trm index, why won't like/2 or ilike/2 work? when entering in full name "asymptote", able find record.

i faced similar problem. unfortunately had no pg_trgm available. used in:

  candidate in query,   where: like(candidate.first_name, ^("%#{text}%")) 

this matched text in place of candidate.first_name.


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -