title: Postgres...how to improve ilike results (quality not speed)
body: <p>I have a list of chemicals in my database and I provide our users with the ability to do a live search via our website.  I use SQLAlchemy and the query I use looks something like this:</p>
  
  <pre><code>Compound.query.filter(Compound.name.ilike(f'%{name}%')).limit(50).all() 
  </code></pre>
  
  <p>When someone searches for <strong>toluene</strong>, for example, they don't get the result they're looking for because there are many chemicals that have the word toluene in them, such as:</p>
  
  <ul>
  <li>2, 4 Dinitrotoluene </li>
  <li>2-Chloroethyl-p-toluenesulfonate </li>
  <li>4-Bromotoluene</li>
  <li>6-Amino-m-toluenesulfonic acid </li>
  <li>a,2,4-trichlorotoluene</li>
  <li>a,o-Dichlorotoluene </li>
  <li>a-Bromtoluene </li>
  <li>etc...</li>
  </ul>
  
  <p>I realize I could increase my <code>limit</code> but I feel like 50 is more than enough.  Or, I could change the <code>ilike(f'%{name}%'))</code> to something like <code>ilike(f'{name}%'))</code> but our business requirements don't want this.   What I'd rather do is improve the ability for Postgres to return results so that <strong>toluene</strong> is at the top of the search results.</p>
  
  <p>Any ideas on how Postgres' ilike capability?  </p>
  
  <p>Thanks in advance.</p>