I'm implementing an auto-suggest feature in Solr, and I'll like to achieve
the follwing:

For example, if the user enters "mp3", Solr might suggest "mp3 player",
"mp3 nano" and "mp3 music".
When the user enters "mp3 p", the suggestion should narrow down to "mp3
player".

Currently, when I type "mp3 p", the suggester is returning words that
starts with the letter "p" only, and I'm getting results like "plan",
"production", etc, and it does not take the "mp3" token into consideration.

I'm using Solr 5.1 and below is my configuration:

In solrconfig.xml:

<searchComponent name="suggest" class="solr.SuggestComponent">
  <lst name="suggester">

                 <str name="lookupImpl">FreeTextLookupFactory</str>
                 <str name="indexPath">suggester_freetext_dir</str>

<str name="dictionaryImpl">DocumentDictionaryFactory</str>
<str name="field">Suggestion</str>
<str name="weightField">Project</str>
<str name="suggestFreeTextAnalyzerFieldType">suggestType</str>
<int name="ngrams">5</int>
<str name="buildOnStartup">false</str>
<str name="buildOnCommit">false</str>
  </lst>
</searchComponent>


In schema.xml

<fieldType name="suggestType" class="solr.TextField"
positionIncrementGap="100">
<analyzer type="index">
<charFilter class="solr.PatternReplaceCharFilterFactory"
pattern="[^a-zA-Z0-9]" replacement=" " />
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.ShingleFilterFactory" minShingleSize="2"
maxShingleSize="6" outputUnigrams="false"/>
</analyzer>
<analyzer type="query">
<charFilter class="solr.PatternReplaceCharFilterFactory"
pattern="[^a-zA-Z0-9]" replacement=" " />
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.ShingleFilterFactory" minShingleSize="2"
maxShingleSize="6" outputUnigrams="true"/>
</analyzer>
</fieldType>


Is there anything that I configured wrongly?


Regards,
Edwin

Reply via email to