Say I have a list of about 17,000 drug names that I want to be able to search: [Acetaminophen, Ibuprofen, Xanax, percocet, etc]. I want to be able to suggest drugs from the list as a user is typing.
However, as I have it, when I type "ibup", the suggestions are
"I-123 MIBG"
"I 123 Mini"
"I-131 Mini"
"I-Prin (Oral)" etc.....
I would expect "Ibuprofen" to be one of, if not the top, result in the list of suggestions. How do I define a field
and fieldType
so that it works well with a suggester.
The field type of each drug name is the default text_general that comes built in:
<fieldType name="text_general" class="solr.TextField" positionIncrementGap="100" multiValued="true">
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" />
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" />
<filter class="solr.SynonymGraphFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
I am using the FuzzyLookupFactory to suggest drug names from the list. My search component and request handler look like this:
<searchComponent name="suggest" class="solr.SuggestComponent">
<lst name="suggester">
<str name="name">mySuggester</str>
<str name="lookupImpl">FuzzyLookupFactory</str>
<str name="storeDir">fuzzyDirectory</str>
<str name="dictionaryImpl">DocumentDictionaryFactory</str>
<str name="field">drugName</str>
<str name="suggestAnalyzerFieldType">text_general</str>
<str name="buildOnStartup">false</str>
<str name="buildOnCommit">false</str>
</lst>
</searchComponent>
<requestHandler name="/suggesthandler" class="solr.SearchHandler" startup="lazy" >
<lst name="defaults">
<str name="suggest">true</str>
<str name="suggest.count">10</str>
<str name="suggest.dictionary">mySuggester</str>
</lst>
<arr name="components">
<str>suggest</str>
</arr>
</requestHandler>