How to implement solr4.7 spell check
This article focuses on "how to achieve solr4.7 spell checking". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to implement solr4.7 spell check".
Unlike other fields, ① spell checking requires word segmentation when indexing, but no word segmentation is needed for retrieval, so create a special field for spell checking:
Set what fields are in the required spell check fields in the schema.xml file:
② is set in the solrconfig.xml file:
Text_spell default spell solr.DirectSolrSpellChecker internal 0.5 2 1 5 2 0.01 solr.FileBasedSpellChecker file spellings.txt UTF-8 spellcheckerFile spell default on true true spellerror
Code in ③ solrj
/ * * @ method: testSpellCheck * @ Description: spell check * * @ author: ChenYW * @ date 2014-4-15 06:14:56 * / public String spellCheck (String word) {SolrQuery query = new SolrQuery (); query.set ("defType", "edismax"); / / weighted query.set ("qf", "name ^ 20.0") Query.set ("spellcheck", "true"); query.set ("spellcheck.q", word); query.set ("qt", "/ spell"); query.set ("spellcheck.build", "true"); / / when new check words are encountered, query.set is automatically added to the index ("spellcheck.count", 5) Try {QueryResponse rsp = server.query (query); SpellCheckResponse re=rsp.getSpellCheckResponse (); if (re! = null) {if (! re.isCorrectlySpelled ()) {String t = re.getFirstSuggestion (word); / / get the first recommendation System.out.println ("recommendation:" + t); return t } catch (SolrServerException e) {e.printStackTrace ();} return null;} at this point, I believe you have a better understanding of "how to implement solr4.7 spell checking". You might as well do it in practice! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!