Posts

Showing posts with the label solr spellchecker

Using Solr Spellchecker from Java

Continuing from my prevoius post Implementing Spellchecker in Solr , we'll now see how to use SorlJ API to fetch spellcheck suggestions through a Java program. public static Map<String, List<String>> getSuggestions(String queryStr){ if (queryStr != null &&  !queryStr.isEmpty()) { try { SolrServer server = new HttpSolrServer("http://localhost:8983/solr ");    ModifiableSolrParams params = new ModifiableSolrParams();    params.set("qt", "/spell");    params.set("q", queryStr);    params.set("spellcheck", "true");    params.set("spellcheck.collate", "true");    QueryResponse response = server.query(params);    System.out.println("response = " + response);    if(response != null){       SpellCheckResponse scr = response.getSpellCheckResponse();     if(scr != null...

Implementing Spellchecker in Solr

A common need in search applications is suggesting correct word/ phrase for a misspelled word / phrase. These suggestions may come from a dictionary that is based upon some field or upon any other arbitrary dictionary.  Implementing a spell-check suggester in Apace Solr is a piece of cake. All you need is to follow the given steps and you are done. Step 1: Open <SOLR_HOME>/example/solr/conf/solrconfig.xml and search for  <lst name=" spellchecker " >   under this tag make changes to  <str name=" field " > name </str>  in place of    name   define your field which will be referred for spell checking Now we have to update the spell requestHandler settings, to do so search for  <requestHandler name="/ spell " class=" solr.SearchHandler " startup=" lazy " > and under this tag make changes to <str name=" df " > text </str>  in place of    ...