↓ Skip to main content

Rails Sunspot/Solr returning result for single character searches

·101 words·1 min

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;
    <br /> <fieldType name="text" class="solr.TextField" omitNorms="false"><br /> <analyzer><br /> <tokenizer class="solr.StandardTokenizerFactory"/><br /> <filter class="solr.StandardFilterFactory"/><br /> <filter class="solr.LowerCaseFilterFactory"/><br /> <filter class="solr.PorterStemFilterFactory"/><br /> <filter class="solr.NGramFilterFactory" minGramSize="1" maxGramSize="15"/> <!-- This is The New Line --><br /> </analyzer><br /> </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.