Example usage for org.apache.solr.client.solrj.response SpellCheckResponse isCorrectlySpelled

List of usage examples for org.apache.solr.client.solrj.response SpellCheckResponse isCorrectlySpelled

Introduction

In this page you can find the example usage for org.apache.solr.client.solrj.response SpellCheckResponse isCorrectlySpelled.

Prototype

public boolean isCorrectlySpelled() 

Source Link

Usage

From source file:com.nridge.ds.solr.SolrResponseBuilder.java

License:Open Source License

private void populateSpelling(QueryResponse aQueryResponse) {
    Logger appLogger = mAppMgr.getLogger(this, "populateSpelling");

    appLogger.trace(mAppMgr.LOGMSG_TRACE_ENTER);

    SpellCheckResponse spellCheckResponse = aQueryResponse.getSpellCheckResponse();
    if (spellCheckResponse != null) {
        mDocument.addRelationship(Solr.RESPONSE_SPELLING, createSpellCheckBag());
        Relationship spellingRelationship = mDocument.getFirstRelationship(Solr.RESPONSE_SPELLING);
        if (spellingRelationship != null) {
            DataBag spellingBag = spellingRelationship.getBag();
            spellingBag.setValueByName("suggestion", spellCheckResponse.getCollatedResult());
            spellingBag.setValueByName("is_spelled_correctly", spellCheckResponse.isCorrectlySpelled());
        }//from   ww  w.java 2  s.c  om
    }

    appLogger.trace(mAppMgr.LOGMSG_TRACE_DEPART);
}

From source file:edu.ub.ir.oof1.service.Solr.java

private List<String> spellcheck(QueryResponse resp) {
    List<String> out = null;
    try {//from w  ww  .  j  a  v a  2s.c  o  m
        SpellCheckResponse spellResp = resp.getSpellCheckResponse();

        if (!spellResp.isCorrectlySpelled()) {
            for (Suggestion suggest : resp.getSpellCheckResponse().getSuggestions()) {
                System.out.println(suggest.getAlternatives());
                out = suggest.getAlternatives();
                if (out != null) {
                    break;
                }
            }
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
    return out;
}