Rails Sunspot/Solr returning result for single character searches

Posted on Wed 17 July 2013 in WebDev & Code

I spent 8 hours trying to get this to work. I googled and found lots of people asking the question but no one with a solution, or rather the given solutions wasn't working for me.

1) rake sunspot:solr:stop

2) Edit the solr/conf/schema.xml file;
<fieldType name="text" class="solr.TextField" omitNorms="false"> <analyzer> <tokenizer class="solr.StandardTokenizerFactory"/> <filter class="solr.StandardFilterFactory"/> <filter class="solr.LowerCaseFilterFactory"/> <filter class="solr.PorterStemFilterFactory"/> <filter class="solr.NGramFilterFactory" minGramSize="1" maxGramSize="15"/> <!-- This is The New Line --> </analyzer> </fieldType>

3) rake sunspot:solr:start

4) rake sunspot:reindex

I think my problem was changing the schema but not restarting the solr server. Restarting the rails server isn't enough.