title: Postgres full text search rank by position
body: <p>I have a table of movies, and I want to search on the titles and return the closest match.</p>
  
  <p>I thought full text search might be useful, but it doesn't seem to be able to order by position of the words, although postgres knows the position. Is this possible in postgres?</p>
  
  <p>Here is my query:</p>
  
  <pre><code>SELECT collectibles.id, collectibles.title, ts_rank_cd(to_tsvector('english', collectibles.title), plainto_tsquery('old school')) AS score
  FROM collectibles WHERE to_tsvector('english', collectibles.title) @@ plainto_tsquery('old school')
  ORDER BY score DESC;
  </code></pre>
  
  <p>Here are some of the results: (this is the best formatting I can seem to figure out, sorry!)</p>
  
  <pre><code>id | title | score
  
   - 277568 | Wilson Meadows: Live At The 15th Old School &amp; Blues Festival | 0.1
   - 3545 | 5 Film Collection: Will Ferrell: Campaign / Old School (Unrtated Version) / Blades Of Glory / Roxbury / Semi-Pro | 0.1
   - 10366 | Alice Cooper: Old School: 1964-1974 (DVD/CD Combo) | 0.1
   - 13004 | American Classics: Old School (3-Disc Set) | 0.1
   - 13005 | American Classics: Old School: Classic Chevrolets | 0.1
   - 13006 | American Classics: Old School: Classic Travel Trailers | 0.1
   - 13007 | American Classics: Old School: Kings Of Kustomizing | 0.1
   - 14592 | Anchorman: The Legend Of Ron Burgundy (Widescreen/ Extended Edition) / Old School (R-Rated Version) (Back-To-Back) | 0.1
   - 14593 | Anchorman: The Legend Of Ron Burgundy (Widescreen/ Extended Edition) / Old School (R-Rated Version) (Side-By-Side) | 0.1
   - 20242 | Audiovisualize: Mixed By Addictive TV: Snake Worship Island / Corp. Inc. / Old School Futures / These Melodies / Robot War / ... | 0.1
   - 192057 | Old School (DreamWorks/ Widescreen/ Unrated Version/ Special Edition) | 0.1
   - 192058 | Old School (DreamWorks/ Widescreen/ Unrated Version/ Special Edition) / Road Trip (R-Rated) (Back-To-Back) | 0.1
   - 192059 | Old School (DreamWorks/ Widescreen/ Unrated Version/ Special Edition) / Road Trip (R-Rated) (Side-By-Side) | 0.1
   - 192060 | Old School (DreamWorks/ Widescreen/ Unrated Version/ Special Edition) / Road Trip (Unrated) (Back-To-Back) | 0.1
   - 192061 | Old School (DreamWorks/ Widescreen/ Unrated Version/ Special Edition) / Road Trip (Unrated) (Side-By-Side) | 0.1
   - 192062 | Old School (Warner Brothers/ R-Rated Version) | 0.1
   - 192063 | Old School (Warner Brothers/ R-Rated Version/ Blu-ray) | 0.1
   - 192064 | Old School (Warner Brothers/ Unrated Version) | 0.1
   - 192065 | Old School (Warner Brothers/ Unrated Version/ Blu-ray) | 0.1
   - 192066 | Old School Comedy (4-Pack): Atoll K / Jack And The Beanstalk / The Flying Deuces / Africa Screams | 0.1
   - 192067 | Old School Hip Hop Dance #1: Beginner | 0.1
   - 192068 | Old School Hip Hop Greatest | 0.1
   - 192069 | Old School Hip Hop: Run DMC &amp; Flava Flav (2-Disc) | 0.1
   - 192070 | Old School Hits Movie Marathon Collection (3-Disc) | 0.1
   - 192071 | Old School Returns | 0.1
  </code></pre>
  
  <p>The score for all of these is 0.1, but the position of the words in many of the titles are closer to the front of the string. Is there any way to rank those as higher? The length of the string or id aren't really good qualifiers of rank, unfortunately.</p>