title: Elasticsearch autocomplete sort by length
body: <p>I want to make an autocomplete with elasticsearch<br><br>
  I have tried<br></p>
  
  <ul>
  <li>naive prefix matching, </li>
  <li><a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-phrase.html" rel="nofollow noreferrer">https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-phrase.html</a></li>
  <li><a href="http://davewalk.net/2015/04/13/address-autocomplete-in-go-and-elasticsearch-part-1.html" rel="nofollow noreferrer">http://davewalk.net/2015/04/13/address-autocomplete-in-go-and-elasticsearch-part-1.html</a></li>
  </ul>
  
  <p>however all of them doesn't meet my expectation</p>
  
  <p>suppose I have data like:</p>
  
  <pre><code>PHP Programing
  php prado framework
  OOP PHP Programming
  PHPMyAdmin
  PHP
  Php
  </code></pre>
  
  <p>whenever I query <code>PHP</code>, the result will be like above list ^ <br>
  How to make PHP show first? instead of last <br>
  and how come PHP Programming has higher weight than PHP which is the equal to the query?<br></p>
  
  <p>note: I already added lowercase filter so the query is treated as case-sensitive, which is why both <code>php, Php, PHP</code> match the query</p>