Why does the autocomplete return incomplete words? I am working on an autocomplete feature based on the Search API Autocomplete module. Basically I almost copied the functions I needed from this module for my use case. I set up a Solr index, and I am trying to query it, so it returns back relevant suggestions.

The problem is that the words returned are not always the words I am expecting. For example, if I enter Pu, the module should return Publication because this word is present in some nodes; it returns Public, which is not even present anywhere. From where does this mysterious word come? I don't know if the problem is with Solr index or Search API module, since they are twice involved in the module.

They are a lot of errors. Here are some examples of the issue.


studi instead of studies
strategi instead of strategies
describ  instead of describe
Actually the issue was related with stemming algorithms as Clive mentioned first. By removing this line in fieldType name="text" in schema.xml file, autocomplete was repaired: 

&lt;filter class="solr.SnowballPorterFilterFactory" language="English" protected="protwords.txt"/&gt; 


So, after I disabled stemming everything was good with autocomplete feature (either contrib module and my custom one), but unfortunately there was a new problem with standard queries (using Search API and views module); those were no more working. Then I managed to solve all issues my changing the analyzer of fieldType name="text" to this one.

&lt;!-- An unstemmed text field - good if one does not know the language of the field --&gt;

&lt;fieldType name="text_und" class="solr.TextField" positionIncrementGap="100"&gt;
  &lt;analyzer type="index"&gt;
    &lt;tokenizer class="solr.WhitespaceTokenizerFactory"/&gt;
    &lt;filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" /&gt;
    &lt;filter class="solr.WordDelimiterFilterFactory"
            protected="protwords.txt"
            generateWordParts="1"
            generateNumberParts="1"
            catenateWords="1"
            catenateNumbers="1"
            catenateAll="0"
            splitOnCaseChange="0"/&gt;
    &lt;filter class="solr.LengthFilterFactory" min="2" max="100" /&gt;
    &lt;filter class="solr.LowerCaseFilterFactory"/&gt;
  &lt;/analyzer&gt;
  &lt;analyzer type="query"&gt;
    &lt;tokenizer class="solr.WhitespaceTokenizerFactory"/&gt;
    &lt;filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/&gt;
    &lt;filter class="solr.StopFilterFactory"
            ignoreCase="true"
            words="stopwords.txt"
            enablePositionIncrements="true"
            /&gt;
    &lt;filter class="solr.WordDelimiterFilterFactory"
            protected="protwords.txt"
            generateWordParts="1"
            generateNumberParts="1"
            catenateWords="0"
            catenateNumbers="0"
            catenateAll="0"
            splitOnCaseChange="0"/&gt;
    &lt;filter class="solr.LengthFilterFactory" min="2" max="100" /&gt;
    &lt;filter class="solr.LowerCaseFilterFactory"/&gt;
  &lt;/analyzer&gt;
&lt;/fieldType&gt;


With this definition for my text fields, everything works perfectly. Even accented characters are correctly returned, so it fits exactly my use case, as system is indexing english and french publications.

Thanks