Hi All,
We are using solr 9.5 and tried to build an autocomplete/autosuggest
functionality.
It should work like this:
If I enter the first letter, it should return e.g. 10 words that start with
this letter – then the second letter and so on …
I have tried the following:
1. Creating a field-type:
<fieldType name="suggestion_text" class="solr.TextField"
positionIncrementGap="100">
<analyzer>
<tokenizer
class="solr.StandardTokenizerFactory" />
<filter name="edgeNGram" minGramSize="1"
maxGramSize="40"/>
<filter name="lowercase"/>
<filter name="germanNormalization"/>
<filter name="germanLightStem"/>
<filter
class="solr.RemoveDuplicatesTokenFilterFactory"/>
</analyzer>
</fieldType>
2. Create the field:
<field name="_suggest_" type="suggestion_text" indexed="true" stored="true"
multiValued="true"/>
3. Copy Values into the field:
<copyField source="title" dest="_suggest_"/>
<copyField source="subtitle" dest="_suggest_"/>
<copyField source="description" dest="_suggest_"/>
4. Create a suggester
<searchComponent name="suggest" class="solr.SuggestComponent">
<lst name="suggester">
<str name="name">mySuggester</str>
<str name="lookupImpl">BlendedInfixLookupFactory</str>
<str name="dictionaryImpl">DocumentDictionaryFactory</str>
<str name="field">_suggest_</str>
<!--str name="weightField">subtitle</str-->
<str name="suggestAnalyzerFieldType">text_de</str>
<str name="highlight">false</str>
<str name="buildOnStartup">true</str>
</lst>
<sarchComponent>
5. And finally we created a request handler:
<requestHandler name="/suggest" class="solr.SearchHandler" startup="lazy">
<lst name="defaults">
<str name="suggest">true</str>
<str name="suggest.count">20</str>
</lst>
<arr name="components">
<str>suggest</str>
</arr>
</requestHandler>
That works in a certain way we get whole phrases which contain our
searchstring.
But what we want is in a first step the first word and if the query contains a
second then the combination of one and two.
An other issue is that this configuration won’t exclude stopwords. E.g. if I
enter a ‘t’ I got suggestions, if i added an o like ‘to’ there wheren’t any
suggestions and with the 3rd letter the suggestions came back …
I am happy about anny suggestions that would bringt me in the right direction.
Thanks in advance.
----------------------------------------------------------------------------------------
Franz Hauser
Softwareentwickler
Kaindl Informatics GmbH
Neufeldweg 71, 8010 Graz
E-Mail: <mailto:[email protected]> [email protected]
Tel: +43 316 474749-14
Fax: +43 316 474749-10
<http://www.kaindl.info/> www.kaindl.info | <http://www.esrasoft.com/>
www.esraSoft.com