I use Solr 6.4 with Haystack 2.6.1, pySolr 3.6:

I'm looking for a google like suggestions autocomplete. Actually use EdgeNGram works good but it returns my documents titles only what is not what I want:

example:

```
typing: 'new y'
return:

New york, fabulous city that never sleep
A trip to new york by night
...

```

This give the user only the choice to select a document in particular in the suggestion list and the search will return only document with search based on suggested title.

What I want is a suggestion of revelants words like:

```
typing: 'new y'
return:

new york
new york by night
new york city
trip to new york

```

There is an article that suggest to use indexed queries by users that return results and then to use these queries as suggestions:
<https://lucidworks.com/2009/09/08/auto-suggest-from-popular-queries-using-edgengrams/>

This mean parsing solr log or use a Data import (DIH) from a bunch of saved user's queries in DB.

Actually this article is pretty old (2009) and since then Solr have bring to us the Suggester (<https://cwiki.apache.org/confluence/display/solr/Suggester>)

Anyway I wonder if there is actually a good tutorial on how to use Suggester with revelant queries instead of returning my documents titles without the need to save the user's queries in DB, import them via scheduled process, reindexing, etc.

My search\_indexes.py

```
class ArticleIndex(indexes.SearchIndex, indexes.Indexable): 

    text = indexes.CharField(document=True, use_template=True)
    created = indexes.DateTimeField(model_attr='created')
    rating = indexes.IntegerField(model_attr='rating')
    title = indexes.CharField(model_attr='title', boost=1.125)
    term = indexes.EdgeNgramField(model_attr='title')

    def get_model(self):
            return Article

```

My article\_text.txt 

```
{{ object.title }}
{{ object.created }}
{{ object.rating }}

```

My schema.xml

```
<field name="term" type="text_general" indexed="true" stored="true" />
<field name="weight" type="float" indexed="true" stored="true" />

<fieldType name="edge_ngram" class="solr.TextField" positionIncrementGap="1">
  <analyzer>
    <tokenizer class="solr.WhitespaceTokenizerFactory" />
    <filter class="solr.LowerCaseFilterFactory" />
    <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="0" catenateNumbers="0" catenateAll="0" splitOnCaseChange="1"/>
    <filter class="solr.EdgeNGramFilterFactory" minGramSize="2" maxGramSize="15" side="front" />
  </analyzer>
</fieldType>

<fieldType name="suggestType" class="solr.TextField" positionIncrementGap="100">
    <analyzer>
        <charFilter class="solr.PatternReplaceCharFilterFactory" pattern="[^a-zA-Z0-9]" replacement=" " />
        <tokenizer class="solr.WhitespaceTokenizerFactory"/>
        <filter class="solr.LowerCaseFilterFactory"/>
    </analyzer>
</fieldType>

```

My solrconfig.xml

```
<requestHandler name="/suggest" class="solr.SearchHandler" startup="lazy" >
    <lst name="defaults">
        <str name="suggest">true</str>
        <str name="suggest.dictionary">infixSuggester</str>
        <str name="suggest.onlyMorePopular">true</str>
        <str name="suggest.count">10</str>
        <str name="suggest.collate">true</str>
    </lst>
    <arr name="components">
        <str>suggest</str>
    </arr>
</requestHandler>
<searchComponent name="suggest" class="solr.SuggestComponent">
    <lst name="suggester">
        <str name="name">infixSuggester</str>
        <str name="lookupImpl">AnalyzingInfixLookupFactory</str>
        <str name="indexPath">infix_suggestions</str>
        <str name="highlight">false</str>
        <str name="dictionaryImpl">DocumentDictionaryFactory</str>
        <str name="field">term</str>
        <str name="weightField">weight</str>
        <str name="suggestAnalyzerFieldType">suggestType</str>
        <str name="buildOnStartup">false</str>
        <str name="buildOnCommit">false</str>
    </lst>
</searchComponent> 

```

I use pysolr to query Solr as Haystack doesn't have the suggest method implemented yet:

```
from pysolr import Solr

solr = Solr(settings.HAYSTACK_CONNECTIONS['default']['URL'], search_handler='/suggest', use_qt_param=False)
raw_results = solr.search('', **{'suggest.q': query_string})

```