The spellings.txt
file provides file-based spellcheck and it can be enabled by specifying the following code in solrconfig.xml
:
<searchComponent name="spellcheck" class="solr.SpellCheckComponent"> <lst name="spellchecker"> <str name="classname">solr.FileBasedSpellChecker</str> <str name="name">file</str> <str name="sourceLocation">spellings.txt</str> <str name="characterEncoding">UTF-8</str> <str name="spellcheckIndexDir">./spellcheckerFile</str> </lst> </searchComponent>
In this file, you can write a list of correct words. This file is used to define a dictionary for the users. You need to enter each word in a new line shown as follows:
solr
solar
Once the dictionary is created, it needs to be built by calling spellcheck.build
through the URL:
http://<solr-url>/select?q=*:*&spellcheck=true&spellcheck.build=true
Now, you can simply check the spellchecker by calling the following URL:
http://<solr-url>/select?q=solar&spellcheck=true