title: Redis full text search : reverse indexing or sunspot?
body: <p>I have 3,5 millions records (readonly) actually stored in a MySQL DB that I would want to pull out to Redis for performance reasons. Actually, I've managed to store things like this into Redis :</p>
  
  <pre><code>1 {"type":"Country","slug":"albania","name_fr":"Albanie","name_en":"Albania"}
  2 {"type":"Country","slug":"armenia","name_fr":"Arménie","name_en":"Armenia"}
  ...
  </code></pre>
  
  <p>The key I use here is the legacy MySQL id, so with some Ruby glue, I can break as less things as possible in this existing app (and this is a serious concern here).</p>
  
  <p>Now the problem is when I need to perform a search on the keyword "Armenia", inside the value part. Seems like there's only two ways out : </p>
  
  <p><em>Either I multiplicate Redis index</em> : </p>
  
  <ul>
  <li>id => JSON values (as shown above)</li>
  <li>slug => id (reverse indexing based on the slug, that could do the basic search trick)</li>
  <li>finally, another huge index specifically for autocomplete, as shown in this post : <a href="http://oldblog.antirez.com/post/autocomplete-with-redis.html">http://oldblog.antirez.com/post/autocomplete-with-redis.html</a></li>
  </ul>
  
  <p><em>Either I use sunspot</em> or some full text search engine (unfortunatly, I actually use ThinkingSphinx which is too much tied to MySQL :-(</p>
  
  <p>So, what would you do ? Do you think the MySQL to Redis move of a single table is even a good idea ? I'm afraid of the Memory footprint those gigantic Redis key/values could take on a 16GB RAM Server. </p>
  
  <p>Any feedback on a similar Redis usage ?</p>